UNPKG

@lynx-js/web-core

Version:

This is an internal experimental package, do not use

30 lines 1.44 kB
import { triggerElementMethodEndpoint } from '../../endpoints.js'; import { AnimationOperation } from '../../../constants.js'; import { __QuerySelector } from '../elementAPIs/pureElementPAPIs.js'; export function registerTriggerElementMethodEndpointHandler(rpc, lynxViewInstance) { const animationMap = new Map(); rpc.registerHandler(triggerElementMethodEndpoint, (method, id, options) => { if (method === 'animate') { switch (options.operation) { case AnimationOperation.START: animationMap.set(options.id, __QuerySelector(lynxViewInstance.rootDom, id)?.animate(options.keyframes, options.timingOptions)); break; case AnimationOperation.PLAY: animationMap.get(options.id)?.play(); break; case AnimationOperation.PAUSE: animationMap.get(options.id)?.pause(); break; case AnimationOperation.CANCEL: animationMap.get(options.id)?.cancel(); animationMap.delete(options.id); break; case AnimationOperation.FINISH: animationMap.get(options.id)?.finish(); animationMap.delete(options.id); break; } } }); } //# sourceMappingURL=registerTriggerElementMethodEndpointHandler.js.map