원이 일정 시간 이상 확장되는 원 애니메이션이 있습니다. 여기에서 애니메이션을 볼 수 있습니다 : https://rimildeyjsr.github.io/spotify-circle-animation/원 애니메이션 최적화
애니메이션이 오래 동안 실행되면 웹 사이트의 속도가 상당히 느려지는 것입니다. 말 그대로 프레임이 떨어지는 것을 볼 수 있으며 스크롤하는 애니메이션 (fullPage.js 사용)은 화면에서 뒤떨어져 있습니다. 이 때문에 너무 많은 도움하지 않는 것 -
- 그것의 애니메이션의 끝에 도달 할 때 페이지에서 원 div의 제거 :
애니메이션을 최적화하기 위해, 나는 다음을 밖으로 시도 다음 페이지로 스크롤 할 때 픽셀 화로 확대되는 초기 원을 볼 수 있습니다.
제한하는
divs
의 크기는 - 나는 원의 확장 속도가 느려 100 %에scale(50.0,50.0)
에scale(100.0,100.0)
에서 애니메이션 을 변경 시도했다.1000px
에서500px
으로 초기 크기를 변경하려고 시도했는데 이로 인해 서클 확장 속도가 느려집니다. 이 두 가지 솔루션은 최적화에 아무런 영향을 미치지 않지만 애니메이션은 여전히 웹 사이트 속도를 저하시킵니다.시작 모든 부분 스크롤에 애니메이션을 중지 - 나는 이이
afterLoad
및onLeave
콜백을 사용하는 것이 가능하다 fullPage.js을 사용하고 있기 때문에. 문제는 애니메이션을 중단하는 방법을 모른다는 것입니다.
여기 내 코드입니다 :
CSS :
html,body{
padding: 0;
margin: 0;
height: 100%;
width: 100%;
overflow-y: hidden;
overflow-x: hidden;
background-color: #24ccdf;
}
.initial-div {
width: 1000px;
height: 1000px;
transform: scale(0);
}
.position-div{
position: absolute;
border-radius: 50%;
display: none;
}
.animate {
-webkit-animation: expand 2500s;
}
@-webkit-keyframes expand {
0%{
-webkit-transform: scale(0,0);
}
100%{
-webkit-transform: scale(100.0,100.0);
display: none;
}
}
jQuery를 :
var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
function makeDiv(color){
var divsize = 1000;
//$('body').css({'background-color':bgColor});
$newdiv = $('<div/>').addClass('initial-div').css({
'background-color': color
});
var posx = (Math.random() * ($('.section').width()) - (divsize/2)).toFixed();
var posy = (Math.random() * ($('.section').height()) - (divsize/2)).toFixed();
$newdiv.addClass('position-div').css({
'left':posx+'px',
'top':posy+'px'
}).appendTo("#fullpage").addClass('animate').css({'display':'block'}).one(animationEnd,function(){
$(this).remove();
});
}
$(document).ready(function(){
$('#fullpage').fullpage({
anchors: ['home','about','projects','blog','contact'],
fixedElements: '#toggle,#overlay',
afterLoad : function(anchorLink,index) {
if(index == 1 || anchorLink == 'home'){
circleAnimation();
}
else if(index == 2 || anchorLink == 'about'){
$('#section2 h1').addClass('come-in').one(animationEnd,function(){
$('#section2 h3').addClass('come-in').one(animationEnd,function(){
$('#section2 p').addClass('come-in');
});
});
}
}
});
function circleAnimation(){
var colorArray = ['#11256c','#24ccdf'];
var i= 0,flag=0;
var color = colorArray[i];
setInterval(function(){
flag++;
makeDiv(color);
if (flag == 15){
color = colorArray[i];
i++;
if (i == 2) {
i = 0;
}
flag=0;
}
},2000);
}
});
어떤 도움, 힌트 또는 포인터 진심으로 감사합니다. 미리 감사드립니다!
많은 수정 작업을 해주셔서 죄송합니다. 2500s는 확장을 늦추는 것입니다. 속도를 늦출 수있는 방법이있는 경우 시간 속성 대신 해당 속성을 수용 할 준비가되었습니다. 또한 서클은 임의의 위치에서 시작해야하며, 내가 언급 한 것처럼 못생긴 모서리로 이어지는 화면을 벗어나 확장하지 않기를 바랍니다. 저의 유일한 기대는 서클이 시작되고 확장된다는 것입니다. 화면의 절반 이상을 덮으면 색상이 반전되고 애니메이션이 다시 시작됩니다. –
애니메이션에서 원하는 내용을 명확하게 전달했으면 좋겠다. –
설정을 조금만 재생할 수 있습니다. 아마 40 대가 이미 충분히 좋을 것 같습니다. – Gerard