OnBeforeSeek and onSeek switch child div using jQuery Scrollable?

I scroll through some panels that contain some YouTube clips using jQuery Tools scrollable . I would like to hide them during the transition in order to avoid harsh animations.

Markup:

<div id="panel_items">
    <div id="wrap">
        <div class="event">
            <div class="header">Event 1</div><!-- Header is always displayed -->
            <div class="youtube">youtube clips</div><!-- hide during transition, then show -->
        </div>
        <div class="event">
            <div class="header">Event 2</div>
            <div class="youtube" style="display: none">More youtube clips</div>
        </div>
    </div>
</div>

Current JS:

$("#panel_items").scrollable({
  onBeforeSeek: function() { console.log("hide .child .youtube"); }, 
  onSeek: function() { console.log("Show child .youtube"); }        
});

Bonus question: how can I automatically set the height #panel_itemsaccording to the current panel height ( .event)?

+3
source share
3 answers

Something like this might work (unverified):

$("#panel_items").scrollable({
   onBeforeSeek: function() { this.getItems().css({'visibility': 'hidden'}); }, 
   onSeek: function() { this.getItems().css({'visibility': 'visible'});}
});  
+1
source

Have you tried it like this?

var api = jQuery("#panel_items").data("scrollable");

api.onBeforeSeek(function() {

    jQuery(". youtube").fadeOut(100);

});
+1
source

fadein fadeout . :

onBeforeSeek: function (e,i) {
    $(".items").animate({opacity:0},400);
},
onSeek: function (e,i) {
    $(".items").animate({opacity:1},400);
}
0

Source: https://habr.com/ru/post/1740676/


All Articles