我試圖使用基本函數來檢測窗口寬度,但是,該函數並未在調整大小上進行更新。調整事件未觸發
它基本上是一個電子郵件註冊表單,可以從鼠標懸停時的畫布動畫化。
我不希望事件在屏幕小於768px時觸發。
CODE
(function ($) {
var config = {};
$(document).ready(function() {
config.window = $(window);
// Resize
$(window).on("resize", function() {
resizeWindow();
}).trigger("resize");
if (config.wWidth > 768) {
buildCanvas();
}
// EMail Signup
var $container = $('.email-signup__wrap'),
$cHeight = $('.email-signup').outerHeight();
function buildCanvas() {
$('.email-signup__wrap').on('mouseenter mouseleave', function(e) {
e.preventDefault();
var $this = $(this);
$container.toggleClass('active');
if ($container.hasClass('active')) {
TweenMax.to($container, .4, {
ease: Power2.easeOut,
css:{
overflow: 'visible',
position: 'absolute',
top: -$cHeight
}
});
} else {
TweenMax.to($container, .4, {
ease: Power2.easeOut,
css:{
position: 'relative',
top: 0
},
onComplete: hide
});
function hide(){
$container.css('overflow', 'hidden');
}
$("div.mce_inline_error").remove();
}
});
}
function resizeWindow() {
config.wWidth = config.window.width();
config.wHeight = config.window.height();
}
});
}(jQuery));
爲什麼你把'$(文件)。就緒內的JS功能() '?這可能是一個問題。 –
請提供一個JSFiddle,以便我們可以查看您的代碼。 –
你可以儘可能地標記我:)這太緊急了,不用擔心。我會檢查現在Wissam –