Skip to content

Instantly share code, notes, and snippets.

@croosen
Last active December 21, 2016 11:39
Show Gist options
  • Save croosen/e08d598b955e535c317c6e11afad1453 to your computer and use it in GitHub Desktop.
Save croosen/e08d598b955e535c317c6e11afad1453 to your computer and use it in GitHub Desktop.
/*----------------------------------------------------
* Slider, fancy nudgy hover effect
/*----------------------------------------------------*/
function nudgeSlider(){
const $slickNext = $('.slick-next');
const $slickPrev = $('.slick-prev');
const $slickTrack = $('.slick-track');
$slickNext.add($slickPrev).each(function(){
const $this = $(this);
const direction = $this.attr('data-dir');
$this.on({
mouseenter: function () {
if (!$(this).hasClass('slick-disabled')) {
$(this).parent().find($slickTrack).addClass('pull-little-'+ direction +'');
}
},
mouseleave: function () {
$(this).parent().find($slickTrack).removeClass('pull-little-'+ direction +'');
}
});
});
}
/* CSS */
.slick-track {
margin-left: 0;
transition: margin-left 0.3s ease;
}
.pull-little-left {
margin-left: -100px !important; //yes we need this
@media (max-width: $screen-xs-max) {
margin-left: 0 !important;
}
}
.pull-little-right {
margin-left: 100px !important;
@media (max-width: $screen-xs-max) {
margin-left: 0 !important;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment