티스토리 뷰
문법
$('선택자').animate({속성:'값'}, 시간, 가속도함수, 콜백함수);
// 속도함수와 콜백함수는 생략 가능하다.
*콜백 함수를 이용하면 모션이 끝난 바로 그 시점에 새로운 모션이나 특정 기능을 이어서 실행 시킬 수 있다.
jQuery 가속도 함수를 사용하려면 jQuery UI가 필요하다.
<script src="https://code.jquery.com/ui/1.13.0-rc.3/jquery-ui.min.js"></script>
https://releases.jquery.com/ui/
jQuery UI – All Versions | jQuery CDN
jQuery UI – All Versions jQuery UI - Git Builds UNSTABLE, NOT FOR PRODUCTION jQuery UI 1.13 jQuery UI 1.13.0 - uncompressed, minified Themes base black-tie blitzer cupertino dark-hive dot-luv eggplant excite-bike flick hot-sneaks humanity le-frog mint-ch
releases.jquery.com
*CDN 다운받는 원리는 [jQuery] CDN과 비슷하다.
UI 스크립트가 없는 상태에서 jQuery Easing 함수를 사용하게 되면, 아래와 같은 에러가 발생한다.
Q. 가속도 함수는 어디서 확인할 수 있나요?
Easing Functions Cheat Sheet
Easing functions specify the speed of animation to make the movement more natural. Real objects don’t just move at a constant speed, and do not start and stop in an instant. This page helps you choose the right easing function.
easings.net
그래프를 봐도 감이 잘 안잡히는데요...
jQuery UI
jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you're building highly interactive web applications or you just need to add a date picker to a form control, jQue
jqueryui.com
0. jQuery UI 사이트에 들어간다.
1. "ctrl + f" 단어 검색으로 "Easing"을 찾아서 클릭한다.
2. API documentation를 클릭한다.
3. 스크롤을 내리면 속도를 비교할수 있는 컨텐츠가 있다.
https://api.jqueryui.com/easings/
Easings | jQuery UI API Documentation
Easings Easing functions specify the speed at which an animation progresses at different points within the animation. jQuery core ships with two easings: linear, which progresses at a constant pace throughout the animation, and swing (jQuery core's default
api.jqueryui.com
[주의] animate는 수치가 바뀌는 것만 사용가능하다.
예를 들어 font-size: 16px -> 40px으로 변경 (수치니까 가능)
background: pink -> lightblue로 변경 (수치가 아니기 때문에 불가능)
[해결방법]
이 또한 jQuery UI 스크립트를 연결하는 것이다.
(색을 완전히 인식하지는 못하는 듯하다. lightblue와 rgb 컬러가 적용이 되지 않았다.)
.stop() 모션의 중첩 끊어주기
$('선택자').stop().animate({속성: '값'}, 시간, 속도함수, 콜백함수);
// stop()은 .animate()메서드 앞에 추가한다.
// stop()의 값은 Boolean이고, 기본 값은 true이다.
// 속도함수와 콜백함수는 생략 가능하다.
.animate는 선택한 요소에 마우스를 빠르게 올렸다 내리기를 반복하면 반복한 횟수만큼 모션이 중첩해서 계속 실행되는 것을 확인할 수 있다. 이처럼 반복되는 모션의 중첩을 끊어주기 위한 구문이 .stop() 메서드이다.
[공부좌표]
'이론 > jQuery' 카테고리의 다른 글
[jQuery] .filter() (0) | 2021.10.23 |
---|---|
[jQuery] 선택자의 순서 값을 찾아주는 .index() 메서드 (0) | 2021.10.23 |
[jQuery] 탐색 구문 .children() .parent() .find() .eq() 등 (0) | 2021.10.22 |
[jQuery] HTML에서 선택한 요소의 속성 변경하는 방법 .attr() (0) | 2021.10.22 |
[jQuery] 실행 시점 제어하기 .on() (0) | 2021.10.22 |
- Total
- Today
- Yesterday
- 객체의 프로퍼티
- offsetHeight
- 점 표기법
- scrollHeight
- 일치 연산자
- offsetTop
- property
- outerHeight
- constructor
- javascript class
- clientHeight
- 동치 연산자
- clinetTop
- __proto__
- 동등 연산자
- scrollTop
- 링크막기 #a링크막기
- [[Prototype]]
- innerHeight
- prototype 프로퍼티
- 대괄포 표기법
- 부등 연산자
- @font-face
- 프로퍼티
- 불일치 연산자
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |