JSDM

HTML

 
1
<div id="bg"></div>
2
<div id="heartbutton">
3
  <svg
4
   xmlns:svg="http://www.w3.org/2000/svg"
5
   xmlns="http://www.w3.org/2000/svg"
6
   version="1.0"
7
   width="200"
8
   height="200" 
9
   id="mainHeart" preserveAspectRatio="none" viewBox="-50 -50 200 200">
10
  <defs
11
     id="defs4" />
12
  <g id="layer1" transform="scale(0.15)" >
13
    <path
14
       d="M 297.29747,550.86823 C 283.52243,535.43191 249.1268,505.33855 220.86277,483.99412 C 137.11867,420.75228 125.72108,411.5999 91.719238,380.29088 C 29.03471,322.57071 2.413622,264.58086 2.5048478,185.95124 C 2.5493594,147.56739 5.1656152,132.77929 15.914734,110.15398 C 34.151433,71.768267 61.014996,43.244667 95.360052,25.799457 C 119.68545,13.443675 131.6827,7.9542046 172.30448,7.7296236 C 214.79777,7.4947896 223.74311,12.449347 248.73919,26.181459 C 279.1637,42.895777 310.47909,78.617167 316.95242,103.99205 L 320.95052,119.66445 L 330.81015,98.079942 C 386.52632,-23.892986 564.40851,-22.06811 626.31244,101.11153 C 645.95011,140.18758 648.10608,223.6247 630.69256,270.6244 C 607.97729,331.93377 565.31255,378.67493 466.68622,450.30098 C 402.0054,497.27462 328.80148,568.34684 323.70555,578.32901 C 317.79007,589.91654 323.42339,580.14491 297.29747,550.86823 z"
15
       id="path2417"
16
       style="fill:#ffffff" />
17
    <g
18
       transform="translate(129.28571,-64.285714)"
19
       id="g2221" />
20
  </g>
21
</svg>
22
</div>

CSS

x
 
1
#bg {
2
  position:fixed;
3
  width:100%;
4
  height: 100%;
5
  background-color:#1e1e1e;
6
}
7
8
body {
9
  margin:0;
10
}
11
12
#heartbutton {
13
  width: 200px;
14
  height: 200px;
15
  background: #424242; /* Old browsers */
16
background: -moz-linear-gradient(top,  #424242 0%, #212123 100%); /* FF3.6+ */
17
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#424242), color-stop(100%,#212123)); /* Chrome,Safari4+ */
18
background: -webkit-linear-gradient(top,  #424242 0%,#212123 100%); /* Chrome10+,Safari5.1+ */
19
background: -o-linear-gradient(top,  #424242 0%,#212123 100%); /* Opera 11.10+ */
20
background: -ms-linear-gradient(top,  #424242 0%,#212123 100%); /* IE10+ */
21
background: linear-gradient(to bottom,  #424242 0%,#212123 100%); /* W3C */
22
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#424242', endColorstr='#212123',GradientType=0 ); /* IE6-9 */
23
24
25
26
  border: 1px solid #010101;
27
  position:relative;
28
  display:block;
29
  border-radius: 5px;
30
  top: 20px;
31
  left: 50%;
32
  margin-left: -100px;
33
}
34
35
#layer1 {
36
  cursor:pointer;
37
}
? ?
? ?
必须是有效的URL
+ 添加另一个资源

JS

xxxxxxxxxx
108
 
1
var love = "#FFAEAE";
2
var extraLove = "#FF8484";
3
var superLove = "#FF4545"
4
var index = 0;
5
$(document).ready(function(){
6
   
7
  $("#layer1").on("click", function(){
8
    window.console.log("clicked");
9
    
10
    if(index === 0){
11
    var clone = $("#mainHeart").clone(false).attr("id","clone1").css({"position":"fixed", "top":20}).appendTo("#heartbutton");
12
    
13
    window.console.log($("#clone1").children("g#layer1").find("path"));
14
    
15
    TweenMax.to($("#clone1"), 1.2, {
16
      x:-5, 
17
      top:10,
18
      scaleX:2.2, 
19
      scaleY:2.2,
20
      opacity:0, 
21
      onStart:function(){
22
      $("#clone1").children("g#layer1").find("path").css("fill",love);
23
      $("#mainHeart").children("g#layer1").find("path").css("fill",love);
24
    }, onComplete:function(){
25
      $("#clone1").remove();
26
    }});
27
      
28
      index += 1;
29
    }
30
    else if(index === 1) {
31
      var clone = $("#mainHeart").clone(false).attr("id","clone2").css({"position":"fixed", "top":20}).appendTo("#heartbutton");
32
      
33
      $("#clone2").children("g#layer1").find("path").css("fill",extraLove);
34
      $("#mainHeart").children("g#layer1").find("path").css("fill",extraLove);
35
      var tl = new TimelineLite({
36
        "paused":true,
37
        smoothChildTiming:true, 
38
        "align":"sequence",
39
        onComplete: function(){
40
        $("#clone2").remove();
41
      }});
42
      
43
      tl.add( TweenMax.to($("#clone2"), 0.5,{
44
        x: -20,
45
        top: -10,
46
        opacity:0.6,
47
        scaleX: 1.6,
48
        scaleY: 1.6,
49
        ease: Linear.easeNone
50
      }) );
51
      
52
      tl.add( TweenMax.to($("#clone2"), 0.6,{
53
        x: 35,
54
        top: 60,
55
        opacity:0,
56
        scaleX: 2.4,
57
        scaleY: 2.4,
58
        ease: Linear.easeNone
59
      }));
60
      
61
      tl.play();
62
      
63
      index += 1;
64
      
65
    }
66
    else if(index === 2) {
67
      var clone = $("#mainHeart").clone(false).attr("id","clone3").css({"position":"fixed", "top":20}).appendTo("#heartbutton");
68
      
69
      $("#clone3").children("g#layer1").find("path").css("fill",superLove);
70
      $("#mainHeart").children("g#layer1").find("path").css("fill",superLove);
71
      var tl = new TimelineLite({
72
        "paused":true,
73
        smoothChildTiming:true, 
74
        "align":"sequence",
75
        onComplete: function(){
76
        $("#clone3").remove();
77
      }});
78
      
79
      tl.add( TweenMax.to($("#clone3"), 0.5,{
80
        x: -50,
81
        top: -20,
82
        opacity:0.6,
83
        scaleX: 2,
84
        scaleY: 2,
85
        ease: Linear.easeNone
86
      }) );
87
      
88
      tl.add( TweenMax.to($("#clone3"), 0.8,{
89
        x: 40,
90
        top: 60,
91
        opacity:0,
92
        scaleX: 3.4,
93
        scaleY: 3.4,
94
        ease: Linear.easeNone
95
      }));
96
      
97
      tl.play();
98
      
99
      index += 1;
100
    }
101
    else {
102
      $("#mainHeart").children("g#layer1").find("path").css("fill","#ffffff");
103
      index = 0;
104
    }
105
    
106
  });  
107
  
108
});
必须是有效的URL
+ 添加另一个资源
Close

文件管理 点击文件查看URL

图片

  1. 暂无文件

CSS

  1. 暂无文件

JavaScript

  1. 暂无文件

其他

  1. 暂无文件
拖动文件到上面的区域或者:
加载中 ..................