From d0aac07a8291bff04be2ca2050007e3cb18e35c5 Mon Sep 17 00:00:00 2001 From: dethe Date: Sat, 18 Apr 2015 23:44:45 -0700 Subject: [PATCH 1/2] fix scroll and move output --- css/app.css | 7 +++++++ css/widget.css | 4 ++-- js/block.js | 29 ++++++++++++++++++++++++++++- js/event.js | 1 + playground.html | 2 +- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/css/app.css b/css/app.css index 687ba709..0c041247 100644 --- a/css/app.css +++ b/css/app.css @@ -43,6 +43,12 @@ body > header > h1{ line-height: 34px; } +body > output{ + flex: 0 0 24px; + background: #EFEDEA; + color: #111111; +} + .menu{ flex: 0 0 34px; background-color: #666666; @@ -182,6 +188,7 @@ sidebar.trashcan:after{ wb-workspace > wb-contains{ border: 2px inset #CCC; position: relative; + padding-bottom: 16px; } wb-contains:empty::before{ diff --git a/css/widget.css b/css/widget.css index 2d8fe1c1..616a35f3 100644 --- a/css/widget.css +++ b/css/widget.css @@ -73,7 +73,7 @@ wb-workspace{ display: flex; flex-direction: column; flex: 2 1; - overflow-x: auto; + /*overflow-x: auto;*/ } wb-workspace > header{ @@ -90,7 +90,7 @@ wb-workspace > wb-locals{ wb-workspace > wb-contains{ flex: 3 1; - overflow-y: auto; + overflow: auto; } @keyframes slidey-stripes { diff --git a/js/block.js b/js/block.js index 6bfa1e9f..dff07373 100644 --- a/js/block.js +++ b/js/block.js @@ -15,6 +15,7 @@ 'use strict'; var elem = dom.html; var workspace = dom.find(document.body, 'wb-workspace'); + var scriptspace = dom.find(document.body, 'wb-workspace > wb-contains'); var selectedType = 'null'; var BLOCK_MENU = document.querySelector('sidebar'); @@ -825,13 +826,36 @@ function startDragBlock(evt){ } if (dragStart === 'script'){ origTarget.classList.add('hide'); - dom.child(origTarget.parentElement, 'input, select').classList.remove('hide'); + var siblingInput = dom.child(origTarget.parentElement, 'input, select'); + if (siblingInput){ + siblingInput.classList.remove('hide'); + } } dragTarget.classList.add('dragging'); dragTarget.style.left = (evt.pageX - 15) + 'px'; dragTarget.style.top = (evt.pageY - 15) + 'px'; } + +function checkForScroll(evt){ + requestAnimationFrame(checkForScroll); + if (!dragTarget){ return; } + var x = Event.pointerX; + var y = Event.pointerY; + var rect = scriptspace.getBoundingClientRect(); + if (x < rect.left){ + scriptspace.scrollLeft -= 5; + }else if (x > rect.right){ + scriptspace.scrollLeft += 5; + } + if (y < rect.top){ + scriptspace.scrollTop -= 5; + }else if (y > rect.bottom){ + scriptspace.scrollTop += 5; + } + console.log('bottom: %s, scrollTop: %s, y: %s', rect.bottom, scriptspace.scrollTop, y); +} + function dragBlock(evt){ if (!dragTarget){ return; } evt.preventDefault(); @@ -1088,6 +1112,9 @@ Event.on(document.body, 'editor:dragging', null, dragBlock); Event.on(document.body, 'editor:drag-end', null, endDragBlock); Event.on(document.body, 'editor:drag-cancel', null, cancelDragBlock); +requestAnimationFrame(checkForScroll); + + Event.on(workspace, 'editor:input', 'input', resizeInputOnChange); Event.on(workspace, 'editor:input', 'input, select', changeValueOnInputChange); diff --git a/js/event.js b/js/event.js index 34473e08..2daa0be5 100644 --- a/js/event.js +++ b/js/event.js @@ -216,6 +216,7 @@ }else{ evt.invalid = true; evt.invalidReason = 'Multiple touches present'; + console.log('multiple touches'); return evt; } evt.target = touch.target; diff --git a/playground.html b/playground.html index 72c4fad3..31c9d261 100644 --- a/playground.html +++ b/playground.html @@ -1079,7 +1079,6 @@

Waterbear with Custom Elements

Workspace
-
@@ -1120,6 +1119,7 @@

Waterbear Tutorials

+ From c6880616692ceed533b7b9ad6a83e34c4b2febd7 Mon Sep 17 00:00:00 2001 From: dethe Date: Sat, 18 Apr 2015 23:51:06 -0700 Subject: [PATCH 2/2] remove commented-out code --- css/widget.css | 1 - 1 file changed, 1 deletion(-) diff --git a/css/widget.css b/css/widget.css index 616a35f3..0dc6ee6a 100644 --- a/css/widget.css +++ b/css/widget.css @@ -73,7 +73,6 @@ wb-workspace{ display: flex; flex-direction: column; flex: 2 1; - /*overflow-x: auto;*/ } wb-workspace > header{