답변 1개
$(document).ready(function() {
let ww = $(window).width();
layout();
function layout() {
if (ww > 1200) {
$(window).scroll(function() {
let h = $(window).scrollTop();
const y = 1 / 4000 * h + 5 / 7;
$('#bigger').css({
transform: `scale(${y})`
});
});
} else {
$(window).off('scroll');
}
}
});
아니면 다음처럼.....
$(document).ready(function() {
function layout() {
let ww = $(window).width();
if (ww > 1200) {
$(window).on('scroll.handleScroll', function() {
let h = $(window).scrollTop();
const y = 1 / 4000 * h + 5 / 7;
$('#bigger').css({
transform: `scale(${y})`
});
});
} else {
$(window).off('scroll.handleScroll');
$('#bigger').css({
transform: 'scale(1)' // 초기화
});
}
}
layout();
$(window).resize(function() {
layout();
});
});
답변에 대한 댓글 2개
function handleScroll() {
let h = $(window).scrollTop();
const y = 1 / 4000 * h + 5 / 7;
$('#bigger').css({
transform: `scale(${y})`
});
}
function layout() {
let ww = $(window).width();
if (ww > 1200) {
$(window).on('scroll.handleScroll', handleScroll);
} else {
$(window).off('scroll.handleScroll', handleScroll);
$('#bigger').css({
transform: 'scale(1)' // 초기화
});
}
}
layout();
$(window).resize(function() {
layout();
});
});
//스크롤 헨들러함수를 별도로 정의 하면 될것같네요 적용해보세요
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인