-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathintersection-actions.js
1 lines (1 loc) · 2.02 KB
/
intersection-actions.js
1
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["video/player/intersection-actions"]=t():e["video/player/intersection-actions"]=t()}(self,(function(){return function(){"use strict";var e={d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t={};e.d(t,{component:function(){return r}});var n,o=coreApis.componentApis.video.playerLight,i=coreApis.observer,a=coreApis.settings;!function(e){e.Top="视频顶部",e.Medium="视频中间",e.Bottom="视频底部"}(n||(n={}));const r={name:"playerIntersectionActions",author:{name:"FoundTheWOUT",link:"https://github.com/FoundTheWOUT"},tags:[componentsTags.video],entry:async({settings:{options:e},metadata:t})=>{const r=e;let s,p,d,u=!0;function c(e){switch(e){case n.Top:return 1;case n.Medium:return.5;case n.Bottom:return 0;default:return.5}}function l(){d.observe(p)}function f(){d.unobserve(p)}const m=e=>new IntersectionObserver((([e])=>{e.isIntersecting?u||(u=!0,r.pause&&s.paused&&s.play(),r.light&&(0,a.getComponentSettings)("playerAutoLight").enabled&&!r.pause&&!s.paused&&(0,o.lightOff)()):(s.paused||(u=!1),r.pause&&!s.paused&&s.pause(),r.light&&(0,a.getComponentSettings)("playerAutoLight").enabled&&!r.pause&&(0,o.lightOn)())}),{threshold:c(e||r.triggerLocation)});(0,a.addComponentListener)(`${t.name}.triggerLocation`,(e=>{f(),d=m(e),l()})),s=dq(".bilibili-player-video video"),p=dq(".player-wrap")||dq(".player-module"),d=m(),(0,i.videoChange)((async()=>{s.addEventListener("play",l),s.addEventListener("ended",f)}))},displayName:"播放器位置动作",description:{"zh-CN":"设置当播放器移出视图的位置变化时执行的动作."},options:{triggerLocation:{defaultValue:n.Medium,displayName:"触发位置",dropdownEnum:n},pause:{defaultValue:!1,displayName:"自动暂停"},light:{defaultValue:!0,displayName:"自动开灯"}}};return t=t.component}()}));