onBeforeSeek 和 onSeek 使用 jQuery Scrollable 切换子 div?

发布于 2024-08-29 04:30:22 字数 1056 浏览 4 评论 0原文

我正在使用 jQuery Tools Scrollable 滚动一些包含一些 YouTube 剪辑的面板。我想在过渡期间隐藏它们以避免动画不稳定。

标记:

<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>

当前 JS:

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

额外问题:如何自动设置 #panel_items 的高度以匹配当前面板高度 (.event)?

I'm scrolling some panels which contain some YouTube clips using jQuery Tools Scrollable. I'd like to hide them during the transition to avoid a jerky animation.

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 of #panel_items to match the current panel height (.event)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烏雲後面有陽光 2024-09-05 04:30:22

像这样的东西可能会起作用(未经测试):

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

Something like this might work (untested):

$("#panel_items").scrollable({
   onBeforeSeek: function() { this.getItems().css({'visibility': 'hidden'}); }, 
   onSeek: function() { this.getItems().css({'visibility': 'visible'});}
});  
怼怹恏 2024-09-05 04:30:22

你有这样尝试过吗? :

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

api.onBeforeSeek(function() {

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

});

Did you try it like that? :

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

api.onBeforeSeek(function() {

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

});
椒妓 2024-09-05 04:30:22

淡入和淡出会导致计数中断。经过一些测试,这有效:

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

fadein and fadeout throws off the count. After some testing, this works:

onBeforeSeek: function (e,i) {
    $(".items").animate({opacity:0},400);
},
onSeek: function (e,i) {
    $(".items").animate({opacity:1},400);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文