aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Layout.mjs7
-rw-r--r--src/dumbymap.mjs5
-rw-r--r--src/editor.mjs13
-rw-r--r--src/utils.mjs2
4 files changed, 16 insertions, 11 deletions
diff --git a/src/Layout.mjs b/src/Layout.mjs
index 51caefb..1279111 100644
--- a/src/Layout.mjs
+++ b/src/Layout.mjs
@@ -123,7 +123,6 @@ export class Overlay extends Layout {
123 } 123 }
124 124
125 enterHandler = ({ htmlHolder, blocks }) => { 125 enterHandler = ({ htmlHolder, blocks }) => {
126
127 // FIXME It is weird rect from this method and this scope are different... 126 // FIXME It is weird rect from this method and this scope are different...
128 blocks.forEach(this.saveLeftTopAsData) 127 blocks.forEach(this.saveLeftTopAsData)
129 128
@@ -144,10 +143,11 @@ export class Overlay extends Layout {
144 </div> 143 </div>
145 ` 144 `
146 145
146 // Set DOMRect for wrapper
147 wrapper.appendChild(block) 147 wrapper.appendChild(block)
148 htmlHolder.appendChild(wrapper)
149 wrapper.style.left = left + "px" 148 wrapper.style.left = left + "px"
150 wrapper.style.top = top + "px" 149 wrapper.style.top = top + "px"
150 htmlHolder.appendChild(wrapper)
151 const { width } = wrapper.getBoundingClientRect() 151 const { width } = wrapper.getBoundingClientRect()
152 left += width + 30 152 left += width + 30
153 if (left > window.innerWidth) { 153 if (left > window.innerWidth) {
@@ -155,10 +155,11 @@ export class Overlay extends Layout {
155 left = left % window.innerWidth 155 left = left % window.innerWidth
156 } 156 }
157 157
158 // Animation for DOMRect
158 animateRectTransition( 159 animateRectTransition(
159 wrapper, 160 wrapper,
160 { left: originLeft, top: originTop }, 161 { left: originLeft, top: originTop },
161 { resume: true, duration: 500 } 162 { resume: true, duration: 300 }
162 ) 163 )
163 .finished 164 .finished
164 .finally(() => this.addDraggable(wrapper)) 165 .finally(() => this.addDraggable(wrapper))
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs
index b5afb6a..7408529 100644
--- a/src/dumbymap.mjs
+++ b/src/dumbymap.mjs
@@ -274,9 +274,10 @@ export const generateMaps = (container, callback) => {
274 placeholder.classList.remove('map-container', 'focus') 274 placeholder.classList.remove('map-container', 'focus')
275 target.parentElement.replaceChild(placeholder, target) 275 target.parentElement.replaceChild(placeholder, target)
276 276
277 // HACK Trigger CSS transition, if placeholde is the olny chil element in block, 277 // FIXME Maybe use @start-style for CSS
278 // Trigger CSS transition, if placeholde is the olny chil element in block,
278 // reduce its height to zero. 279 // reduce its height to zero.
279 // To make sure the original height of placeholder is applied, callBoundingClientRect() seems work(Why?). 280 // To make sure the original height of placeholder is applied, DOM changes seems needed
280 // then set data-attribute for CSS selector to change height to 0 281 // then set data-attribute for CSS selector to change height to 0
281 placeholder.getBoundingClientRect() 282 placeholder.getBoundingClientRect()
282 placeholder.setAttribute('data-placeholder', target.id) 283 placeholder.setAttribute('data-placeholder', target.id)
diff --git a/src/editor.mjs b/src/editor.mjs
index 92513a3..539a770 100644
--- a/src/editor.mjs
+++ b/src/editor.mjs
@@ -151,10 +151,11 @@ const debounceForMap = (() => {
151 let timer = null; 151 let timer = null;
152 152
153 return function(...args) { 153 return function(...args) {
154 clearTimeout(timer);
155 timer = setTimeout(() => {
156 dumbymap = generateMaps.apply(this, args) 154 dumbymap = generateMaps.apply(this, args)
157 }, 1000); 155 // clearTimeout(timer);
156 // timer = setTimeout(() => {
157 // dumbymap = generateMaps.apply(this, args)
158 // }, 10);
158 } 159 }
159})() 160})()
160 161
@@ -542,9 +543,9 @@ document.onkeydown = (e) => {
542 e.preventDefault() 543 e.preventDefault()
543 dumbymap.utils.focusNextMap(e.shiftKey) 544 dumbymap.utils.focusNextMap(e.shiftKey)
544 } 545 }
545 if (e.key === 'x') { 546 if (e.key === 'x' || e.key === 'X') {
546 e.preventDefault() 547 e.preventDefault()
547 dumbymap.utils.switchToNextLayout() 548 dumbymap.utils.switchToNextLayout(e.shiftKey)
548 } 549 }
549 if (e.key === 'n') { 550 if (e.key === 'n') {
550 e.preventDefault() 551 e.preventDefault()
@@ -563,6 +564,7 @@ document.onkeydown = (e) => {
563 564
564// }}} 565// }}}
565// }}} 566// }}}
567// Layout Switch {{{
566const layoutObserver = new MutationObserver(() => { 568const layoutObserver = new MutationObserver(() => {
567 const layout = HtmlContainer.getAttribute('data-layout') 569 const layout = HtmlContainer.getAttribute('data-layout')
568 if (layout !== 'normal') { 570 if (layout !== 'normal') {
@@ -575,5 +577,6 @@ layoutObserver.observe(HtmlContainer, {
575 attributeFilter: ["data-layout"], 577 attributeFilter: ["data-layout"],
576 attributeOldValue: true 578 attributeOldValue: true
577}); 579});
580// }}}
578 581
579// vim: sw=2 ts=2 foldmethod=marker foldmarker={{{,}}} 582// vim: sw=2 ts=2 foldmethod=marker foldmarker={{{,}}}
diff --git a/src/utils.mjs b/src/utils.mjs
index 46632ba..ead3002 100644
--- a/src/utils.mjs
+++ b/src/utils.mjs
@@ -57,7 +57,7 @@ export const animateRectTransition = (element, rect, options = {}) => {
57 return element.animate( 57 return element.animate(
58 keyframes, 58 keyframes,
59 { 59 {
60 duration: options.duration ?? 300, 60 duration: options.duration ?? 500,
61 easing: 'ease-in-out', 61 easing: 'ease-in-out',
62 } 62 }
63 ); 63 );