MCPcopy Create free account
hub / github.com/MankaiHuang/screen-visualization / setTranslate3d

Function setTranslate3d

public/iframe/lib/js/commonFun.js:856–872  ·  view source on GitHub ↗
(translate3d, type, value)

Source from the content-addressed store, hash-verified

854 window.parent.postMessage(params, '*') // 用 iframe 外的toast 防止iframe过大 导致toast显示位置不对
855 },
856 setTranslate3d(translate3d, type, value) {
857 // 设置元素的translate3d属性值
858 if (translate3d === '') {
859 translate3d = 'translate3d(0px,0px,0px)'
860 }
861 const x = translate3d.substring(12).split('px')[0]
862 const y = translate3d.substring(12).split('px')[1].substring(2)
863 if (!String(value).includes('%')) {
864 value += 'px'
865 }
866 if (type === 'left') {
867 return `translate3d(${value},${y}px,0px)`
868 }
869 if (type === 'top') {
870 return `translate3d(${x}px,${value},0px)`
871 }
872 }
873 }
874})

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected