Files
ruo-shan-cloud-pharmacy/miniprogram/package-live/volc-mini-sdk/components/thumb/double-tap-like/like-animation.js
T
陈誉午 994b267f5c feat: 电子药箱小程序 - 4Tab药品管理
- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡
- 药品百科: 搜索 + 分类筛选 + 20种药品静态数据
- 惠教中心: 4条药品使用指南课程
- 我的: 家庭成员信息管理
- 自定义TabBar + navigation-bar组件
- SVG药品分类插图
2026-07-29 11:20:52 +08:00

1 line
2.5 KiB
JavaScript

"use strict";function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,_toPropertyKey(r.key),r)}}function _createClass(t,e,i){return e&&_defineProperties(t.prototype,e),i&&_defineProperties(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.LikeAnimation=void 0;var LikeAnimation=function(){function t(e,i,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];_classCallCheck(this,t),this.x=e,this.y=i,this.canvas=r,this.startTime=Date.now(),this.duration=500,this.imageUrl=o.length>0?o[Math.floor(Math.random()*o.length)]:"../../../assets/thumb.png",this.image=null,this.imageLoaded=!1,this.loadImage(),this.startScale=.5,this.endScale=1.5,this.startRotation=20*(Math.random()-.5),this.offsetY=-60}return _createClass(t,[{key:"loadImage",value:function(){var t=this;if(this.canvas){var e=this.canvas.createImage();e.onload=function(){t.imageLoaded=!0,t.image=e},e.onerror=function(){console.error("Failed to load like animation image:",t.imageUrl)},e.src=this.imageUrl}}},{key:"update",value:function(){var t=Date.now()-this.startTime,e=Math.min(t/this.duration,1);return!(e>=1||(this.progress=e,0))}},{key:"draw",value:function(t){if(this.imageLoaded&&this.image){var e,i,r,o=this.progress||0,a=this.y+this.offsetY*o;e=o<.25?this.startScale+(1-this.startScale)*(o/.25):o<.75?1:1+(this.endScale-1)*((o-.75)/.25),i=o<.25?o/.25:o<.75?1:1-(o-.75)/.25,r=o<.25?this.startRotation:o<.5?this.startRotation*(1-(o-.25)/.25):0,t.save(),t.globalAlpha=i,t.translate(this.x,a),t.rotate(r*Math.PI/180),t.scale(e,e),t.drawImage(this.image,-15,-15,30,30),t.restore()}}}]),t}();exports.LikeAnimation=LikeAnimation;