mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
4.4 KiB
JavaScript
1 line
4.4 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["touch/mini-player"]=t():e["touch/mini-player"]=t()}(self,(function(){return function(){"use strict";var e={304:function(e,t,n){n.r(t),n.d(t,{touchLiveMiniPlayer:function(){return i}});var o=n(569);const i=async e=>{const t=await(0,o.select)(".live-player-ctnr");if(!t)return void console.warn("mini player touch move: player not found");const{enableTouchMove:i,disableTouchMove:r}=await Promise.resolve().then(n.bind(n,110));e?i(t,{minMoveDistance:10}):r(t)}},110:function(e,t,n){n.r(t),n.d(t,{disableTouchMove:function(){return s},enableTouchMove:function(){return c}});var o=coreApis.settings;const i=(e,t)=>new MouseEvent(e,{screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY,bubbles:!0,cancelable:!0,view:unsafeWindow,detail:1}),r=[],a={passive:!1,capture:!0},c=(e,t)=>{if(r.some((t=>t.element===e)))return;let n,c,s;const u=lodash.get(t,"minMoveDistance",(0,o.getComponentSettings)("touchMiniPlayer").options.touchMoveDistance),l=e=>{if(e.touches.length<1)return;const t=e.touches[0];n={x:t.clientX,y:t.clientY},e.target.dispatchEvent(i("mousedown",t))};e.addEventListener("touchstart",l,a);const d=e=>{if(1!==e.touches.length)return;const t=e.touches[0],o={x:t.clientX,y:t.clientY};((e,t,n)=>Math.abs(e.x-t.x)**2+Math.abs(e.y-t.y)**2>=n*n)(n,o,u)?(e.target.dispatchEvent(i("mousemove",t)),s=!0,e.cancelable&&e.preventDefault()):s=!1,c=t};e.addEventListener("touchmove",d,a);const p=e=>{s&&(e.target.dispatchEvent(i("mouseup",c)),e.cancelable&&e.preventDefault(),s=!1)};e.addEventListener("touchend",p,a),e.addEventListener("touchcancel",p,a),r.push({element:e,touchstart:l,touchmove:d,touchend:p})},s=e=>{const t=r.findIndex((t=>t.element===e));if(-1===t)return;const n=r[t];["touchstart","touchmove","touchend"].forEach((t=>{e.removeEventListener(t,n[t],a)})),e.removeEventListener("touchcancel",n.touchend,a),r.splice(t,1)}},421:function(e,t,n){n.r(t),n.d(t,{touchVideoMiniPlayer:function(){return r}});var o=n(569),i=coreApis.style;const r=async e=>{const t=await(0,o.select)("#bilibili-player");if(!t)return void console.warn("mini player touch move: player not found");const{enableTouchMove:r,disableTouchMove:a}=await Promise.resolve().then(n.bind(n,110)),c="touch-mini-player";e?((0,i.addStyle)('// Imports\nvar ___CSS_LOADER_API_IMPORT___ = require("../../../../../node_modules/css-loader/dist/runtime/api.js");\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(function(i){return i[1]});\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, "#bilibili-player.mini-player .drag-bar {\\n touch-action: none !important;\\n height: 40px !important;\\n line-height: 40px !important;\\n top: -40px !important;\\n}\\n#bilibili-player.mini-player .drag-bar i:last-child {\\n margin: 10px !important;\\n}", ""]);\n// Exports\nmodule.exports = ___CSS_LOADER_EXPORT___;\n',c),r(t)):((0,i.removeStyle)(c),a(t))}},569:function(e){e.exports=coreApis.spinQuery}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o](r,r.exports,n),r.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return function(){n.d(o,{component:function(){return i}});var e=coreApis.utils.urls;const t=async e=>{if(document.URL.startsWith("https://live.bilibili.com")){const{touchLiveMiniPlayer:t}=await Promise.resolve().then(n.bind(n,304));await t(e)}else{const{touchVideoMiniPlayer:t}=await Promise.resolve().then(n.bind(n,421));await t(e)}},i={name:"touchMiniPlayer",displayName:"迷你播放器触摸拖动",description:{"zh-CN":"使迷你播放器的拖动条可以触摸拖动."},enabledByDefault:navigator.maxTouchPoints>0,tags:[componentsTags.touch],urlInclude:[...e.videoAndBangumiUrls,...e.liveUrls],entry:()=>t(!0),reload:()=>t(!0),unload:()=>t(!1),options:{touchMoveDistance:{displayName:"拖动触发最小距离",defaultValue:10,hidden:!0}},commitHash:"0a2ab779aac2af6f58d15cee16533dd18200bb62"}}(),o=o.component}()})); |