Top
Fork me on Gitee

js+css 动效+1的效果

点击数值 +1 的动效

vue

data:{
    timer: null,plus:''// 次数
}
method:{
    animate(plus) {
          var _this = this;
          clearInterval(_this.timer);
          _this.timer = setInterval(function () {
               plus--;
               if (plus <= 0) {
                    clearInterval(_this.timer)
               }
               var $i = $("<i>+1</i>");
                $('.popularity-values').append($i);
                $i.animate({
                    "top": '-1.1rem',
                    "right": '-0.9rem',
                    // "top": '-55px',
                    // "right": '-45px',
                    "opacity": 0.1,
                    "fontSize": '0.46rem'
                }, 1800, function () {
                   $i.remove();
               });
           }, 800)
       }
}
jQ 点击 +1 动效
jQuery(document).ready(function ($) {
    $("html,body").click(function (e) {
        // var n = Math.round(Math.random() * 100);
	var n = 1;
	var $i = $("<b/>").text("+" + n);
	var x = e.pageX,
	    y = e.pageY;
	$i.css({
		"z-index": 99999,
		  "top": y - 20,
		  "left": x,
		  "position": "absolute",
		   "color": "#E94F06"
	});
	$("body").append($i);
		$i.animate({
		     "top": y - 180,
		     "opacity": 0
		}, 1500, function () {
		 $i.remove();
	  });
	  e.stopPropagation();
	});
});

posted @ 2019-07-11 15:36  lisashare  阅读(1250)  评论(0编辑  收藏  举报