Created
July 27, 2015 19:05
-
-
Save Walkeryr/abc5498fe1866032c16b to your computer and use it in GitHub Desktop.
controling flexslider opening inside popup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initialize: function () { | |
this.$slider = this.$('.slider'); | |
this.attachPopup(); | |
this.attachSlider(); | |
}, | |
attachPopup: function () { | |
var self = this; | |
$('.press-photo-anchor').magnificPopup({ | |
type: 'inline', | |
callbacks: { | |
elementParse: function (item) { | |
self.$slider.data('flexslider').vars.animationSpeed = 0; | |
}, | |
open: function () { | |
self.$slider.flexslider(this.index); | |
self.$slider.data('flexslider').vars.animationSpeed = 600; | |
} | |
} | |
}); | |
}, | |
attachSlider: function () { | |
var $currentSlide = this.$('#slider-current'), | |
$totalSlides = this.$('#slider-total'), | |
$caption = this.$('#slider-caption'), | |
$slides = this.$('.press-photo-slide'); | |
this.$slider.flexslider({ | |
controlNav: false, | |
prevText: '', | |
nextText: '', | |
start: function (slider) { | |
var caption = $slides.eq(slider.currentSlide).data('caption'); | |
if (caption) { | |
$caption.html(caption); | |
} else { | |
$caption.html(''); | |
} | |
$currentSlide.html(slider.currentSlide + 1); | |
$totalSlides.html(slider.count); | |
$('.slides li img').click(function (event) { | |
event.preventDefault(); | |
slider.flexAnimate(slider.getTarget("next")); | |
}); | |
}, | |
after: function (slider) { | |
var caption = $slides.eq(slider.currentSlide).data('caption'); | |
if (caption) { | |
$caption.html(caption); | |
} else { | |
$caption.html(''); | |
} | |
$currentSlide.html(slider.currentSlide + 1); | |
$totalSlides.html(slider.count); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment