Skip to content

Instantly share code, notes, and snippets.

@Walkeryr
Created July 27, 2015 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Walkeryr/abc5498fe1866032c16b to your computer and use it in GitHub Desktop.
Save Walkeryr/abc5498fe1866032c16b to your computer and use it in GitHub Desktop.
controling flexslider opening inside popup
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