시작페이지로 즐겨찾기추가
로그인
회원가입 l 출석체크 l 마이페이지 l CGIMALL
happycgi
자료실 사이트등록 랭킹100 프로그램리뷰 관리자추천자료 초보가이드
커뮤니티
전체 펼쳐보기
퀵메뉴링크 jquery , CSS , PHP , Javascript , 무료폰트 , ASP
상세검색
 > CSS > 기본 소스 > 검색 애니메이션 상세정보
사이트등록
클라우드태그
Javascript
php
CSS
html
asp
API
jquery
mysql
image
Mobile
slide
게시판
메뉴
현재접속자 25 새로고침
검색 애니메이션
소스통계정보 오류신고 및 문의
해피팀
네티즌
트위터로 보내기 페이스북으로 보내기 네이버로공유
소스분류 기본 소스
다운로드 횟수 4 회
간단설명 검색필드 애니메이션 효과
평가하기 훌륭함 매우좋음 좋음 괜찮음 보통 별로
홈페이지바로가기 데모 미리보기 스크랩하기
 




[HTML 소스]
link(href='https://fonts.googleapis.com/css?family=Roboto+Condensed:700', rel='stylesheet', type='text/css')

h1 This text will be sliced

[CSS 소스]

@import "nib"

body
  background #0099FF

h1
  display block

  absolute top 50% left 50%

  font-family 'Roboto Condensed'
  font-size 50px
  color #1A4C80

  text-transform uppercase

  transform translate(-50%, -50%)

  > span
    display block

    position relative

    float left
    
    overflow hidden

    white-space nowrap

    span
      position absolute





[JS소스]

class Slicer {
  constructor(element, slices, orientation = 'vertical') {
    this.element = element;
    
    this.innerHTML = this.element.innerHTML;
    this.element.style.width = window.getComputedStyle(this.element).width;
    this.element.style.height = window.getComputedStyle(this.element).height;
    
    this.orientation = orientation;
    this.slices = slices;
  }
  
  get slices() {
    return this._slices;
  }
  
  set slices(slices) {
    this._slices = slices;
    this.slice();
  }
  
  slice () {
    var sliceSize = 100 / this.slices;
    
    var span = document.createElement('span');
    span.appendChild(document.createElement('span'));
    span.children[0].innerHTML = this.innerHTML;
    
    if (this.orientation === 'vertical') {
      span.style.width = sliceSize + '%';
      span.style.height = '100%';
    }
    else {
      span.style.width = '100%';
      span.style.height = sliceSize + '%';
    }
    
    while (this.element.firstChild) {
      this.element.removeChild(this.element.firstChild);
    }
    
    this.element.appendChild(span);
    
    var newSpan;
    for (var i = 1; i < this.slices; ++i) {
      newSpan = span.cloneNode(true);
      
      if (this.orientation === 'vertical') {
        newSpan.children[0].style.left = -i * this.slices * sliceSize + '%';
      }
      else {
        newSpan.children[0].style.top = -i * this.slices * sliceSize + '%';
      }

      this.element.appendChild(newSpan);
    }
  }
};

var slicer = new Slicer(document.querySelector('h1'), 116);

var gui = new dat.GUI();
gui.add(slicer, 'slices', 10, 500);

var animate = function () {
  var tl = new TimelineMax();

  tl.staggerFromTo('h1 > span:nth-child(even)', 0.2, {
    y: -20,
    opacity: 0
  }, {
    y: 0,
    opacity: 1
  }, 0.1, 'letter');
  
  tl.staggerFromTo('h1 > span:nth-child(odd)', 0.2, {
    y: 20,
    opacity: 0
  }, {
    y: 0,
    opacity: 1
  }, 0.1, 'letter');
};

var button = {
  animate: animate
};
gui.add(button, 'animate');

animate();

네티즌 의견   이용하신 자료의 후기를 자유롭게 작성하세요. (상업적인 광고 및 도배성 글 등은 사전통보없이 삭제될 수 있습니다.)
내용 아이디 의견남기기
등록된 의견이 없습니다.
1
이름
내용
:네맞아요: :화나는군요: :잠와: :우울해: :이건아냐: :왕하하: 왕웃음~ 놀램~
평가하기 훌륭함 매우좋음 좋음 괜찮음 보통 별로
도배방지키
 63702762 보이는 도배방지키를 입력하세요.