嗨,我正在尝试获取这些平滑的页面过渡效果,但重要的是,将视图调低,以便在视图更改时可以运行javascript。
var Homepage = Barba.BaseView.extend({
namespace: 'home',
onEnter: function() {
// The new Container is ready and attached to the DOM.
$('nav a').on('mouseenter focus', function() {
var item = $(this);
item.addClass('hovered');
setTimeout(function() {
item.removeClass('hovered');
},500);
});
$('.caseStudies a').on('mouseenter focusin mouseleave focusout', function() {
$('.caseStudies .colorContainer').toggleClass('show');
});
$('.recentWork').one('inview', function() {
console.log('in view');
$('.recentWorkInToView').trigger('click');
});
document.querySelector("button.recentWorkInToView").onclick = recentWorkInToView.play;
},
onEnterCompleted: function() {
// The Transition has just finished.
},
onLeave: function() {
// A new Transition toward a new page has just started.
},
onLeaveCompleted: function() {
// The Container has just been removed from the DOM.
}
});
// Don't forget to init the view!
Homepage.init();
$(document).ready(function() {
Barba.Pjax.start();
});
当第一次加载页面时,所有功能都可以完美运行,但是一旦我切换到新页面,然后回到首页,动漫js动画就不会触发。控制台日志“在视图中”确实会触发,所有其他js在视图中起作用。
我真的无法弄清我想念什么或做错了什么。