diff --git a/ekko-lightbox.coffee b/ekko-lightbox.coffee index 83dd284..12c94a5 100644 --- a/ekko-lightbox.coffee +++ b/ekko-lightbox.coffee @@ -60,7 +60,7 @@ EkkoLightbox = ( element, options ) -> $(document).on 'keydown.ekkoLightbox', @navigate.bind(@) # add the directional arrows to the modal - if @options.directional_arrows + if @options.directional_arrows && @gallery_items.length > 1 @lightbox_container.prepend('
') @modal_arrows = @lightbox_container.find('div.ekko-lightbox-nav-overlay').first() @lightbox_container.find('a'+@strip_spaces(@options.left_arrow_class)).on 'click', (event) => @@ -130,37 +130,41 @@ EkkoLightbox.prototype = { do @navigate_left navigate_left: -> - + + if @gallery_items.length == 1 then return + if @gallery_index == 0 then @gallery_index = @gallery_items.length-1 else @gallery_index-- #circular @$element = $(@gallery_items.get(@gallery_index)) @updateTitleAndFooter() src = @$element.attr('data-remote') || @$element.attr('href') - @detectRemoteType(src) + @detectRemoteType(src, @$element.attr('data-type')) navigate_right: -> - + + if @gallery_items.length == 1 then return + if @gallery_index == @gallery_items.length-1 then @gallery_index = 0 else @gallery_index++ #circular @$element = $(@gallery_items.get(@gallery_index)) src = @$element.attr('data-remote') || @$element.attr('href') @updateTitleAndFooter() - @detectRemoteType(src) + @detectRemoteType(src, @$element.attr('data-type')) if @gallery_index + 1 < @gallery_items.length next = $(@gallery_items.get(@gallery_index + 1), false) src = next.attr('data-remote') || next.attr('href') - if @isImage(src) + if next.attr('data-type') == 'image' || @isImage(src) @preloadImage(src, false) - detectRemoteType: (src) -> - if @isImage(src) + detectRemoteType: (src, type) -> + if type == 'image' || @isImage(src) @preloadImage(src, true) - else if video_id = @getYoutubeId(src) + else if type == 'youtube' || video_id = @getYoutubeId(src) @showYoutubeVideo(video_id) - else if video_id = @getVimeoId(src) + else if type == 'vimeo' || video_id = @getVimeoId(src) @showVimeoVideo(video_id) else @error "Could not detect remote target type. Force the type using data-type=\"image|youtube|vimeo\""