File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -117,6 +117,22 @@ export function createIFrameSrc (js) {
117117 window.addEventListener('DOMContentLoaded', () => {
118118 postMsg('iframe_loaded');
119119 });
120+ let flag = false;
121+ window.addEventListener('mousemove', (e) => {
122+ if (!flag) {
123+ flag = true;
124+ setTimeout(() => {
125+ flag = false;
126+ }, 50);
127+ postMsg('mouseevent', ['mousemove', e.clientX]);
128+ }
129+ });
130+ window.addEventListener('mouseup', () => {
131+ postMsg('mouseevent', ['mouseup']);
132+ });
133+ window.addEventListener('mouseenter', () => {
134+ postMsg('mouseevent', ['mouseenter']);
135+ });
120136 var map = (window.jsboxConfig || window.jsboxCodeMap || {}).iifeMap || {};
121137 window.require = (name) => {
122138 let key = map[name];
Original file line number Diff line number Diff line change 77 :title =' (htmlLog?"隐藏":"显示")+"log(ctrl + k)"' ></i >
88 <div class =' log-content' >
99 <div :class =" {'jx-ui': jxUI}" v-show =" !hideHTMLResult" id =' jx-app' >
10- <iframe sandbox =" allow-same-origin allow-scripts" :src =" iframeSrc" style =" height : 100% ;width : 100% ;border : none ;" />
10+ <iframe ref = " iframe " sandbox =" allow-same-origin allow-scripts" :src =" iframeSrc" style =" height : 100% ;width : 100% ;border : none ;" />
1111 </div >
1212 <div v-if =" doc" class =" jx-doc" >
1313 <div class =" jx-doc-title" >{{id}} Docs</div >
135135 }
136136 },
137137 });
138- initDrag (this .$refs .drag );
138+ initDrag (this .$refs .drag , this . $refs . iframe );
139139 this .initLog ();
140140 htmlLog .init (this .htmlLog );
141141 },
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ export function initKeyEvent () {
7171 } ) ;
7272}
7373
74- export function initDrag ( drag ) {
74+ export function initDrag ( drag , iframe ) {
7575 let width = 0 ;
7676 let minWidth = 200 ;
7777 dragPercent . init ( ) ;
@@ -91,6 +91,25 @@ export function initDrag (drag) {
9191 }
9292 dragPercent . stash ( ( ( x ) / width ) * 100 ) ;
9393 } ;
94+
95+ window . addEventListener ( 'message' , ( e ) => {
96+ const data = e . data ;
97+ if ( data . type === 'mouseevent' ) {
98+ const m = data . data [ 0 ] ;
99+ if ( m === 'mousemove' ) {
100+ if ( dragStatus . get ( ) ) {
101+ const x = data . data [ 1 ] + iframe . getBoundingClientRect ( ) . left ;
102+ setSize ( x ) ;
103+ }
104+ } else if ( m === 'mouseup' ) {
105+ if ( dragStatus . get ( ) ) {
106+ setDrag ( false ) ;
107+ }
108+ } else if ( m === 'mouseenter' ) {
109+ setDrag ( false ) ;
110+ }
111+ }
112+ } ) ;
94113 $ . query ( 'body' ) . on ( {
95114 mousemove ( e ) {
96115 if ( dragStatus . get ( ) ) {
You can’t perform that action at this time.
0 commit comments