diff --git a/morphic.js b/morphic.js index 5a53190b..eb07c8e3 100644 --- a/morphic.js +++ b/morphic.js @@ -153,7 +153,7 @@ IV. open issues ---------------- - - clipboard support (copy & paste) + - clipboard support (copy & paste) for non-textual data - native (unscaled) high-resolution display support @@ -169,10 +169,11 @@ - Chrome for Windows - Chrome for Mac - Chrome for Android - - Safari for Windows + - Safari for Windows (deprecated) - safari for Mac - Safari for iOS (mobile) - IE for Windows + - Edge for Windows - Opera for Windows - Opera for Mac @@ -262,10 +263,11 @@ window.onload = function () { world = new WorldMorph( document.getElementById('world')); - setInterval(loop, 50); + loop(); }; function loop() { + requestAnimationFrame(loop); world.doOneCycle(); } @@ -309,10 +311,11 @@ document.getElementById('world1'), false); world2 = new WorldMorph( document.getElementById('world2'), false); - setInterval(loop, 50); + loop(); }; function loop() { + requestAnimationFrame(loop); world1.doOneCycle(); world2.doOneCycle(); } @@ -377,10 +380,11 @@ x = 0; y += 1; } - setInterval(loop, 50); + loop(); }; function loop() { + requestAnimationFrame(loop); world.doOneCycle(); } @@ -1043,6 +1047,7 @@ background texture handling, countless bug fixes and optimizations. Ian Reynolds contributed backspace key handling for Chrome. Davide Della Casa contributed performance optimizations for Firefox. + Jason N (@cyderize) contributed native copy & paste for text editing. - Jens Mönig */ @@ -1052,7 +1057,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2015-December-15'; +var morphicVersion = '2015-December-21'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -4498,17 +4503,17 @@ CursorMorph.prototype.init = function (aStringOrTextMorph) { this.gotoSlot(this.slot); // Add hidden text box for copying and pasting - this.hiddenText = document.createElement('textarea'); - this.hiddenText.style.position = 'absolute'; - this.hiddenText.style.right = '101%'; // placed just out of view + this.clipboardHandler = document.createElement('textarea'); + this.clipboardHandler.style.position = 'absolute'; + this.clipboardHandler.style.right = '101%'; // placed just out of view - document.body.appendChild(this.hiddenText); + document.body.appendChild(this.clipboardHandler); - this.hiddenText.value = this.target.selection(); - this.hiddenText.focus(); - this.hiddenText.select(); + this.clipboardHandler.value = this.target.selection(); + this.clipboardHandler.focus(); + this.clipboardHandler.select(); - this.hiddenText.addEventListener( + this.clipboardHandler.addEventListener( 'keypress', function (event) { myself.processKeyPress(event); @@ -4518,7 +4523,7 @@ CursorMorph.prototype.init = function (aStringOrTextMorph) { false ); - this.hiddenText.addEventListener( + this.clipboardHandler.addEventListener( 'keydown', function (event) { myself.processKeyDown(event); @@ -4535,7 +4540,7 @@ CursorMorph.prototype.init = function (aStringOrTextMorph) { false ); - this.hiddenText.addEventListener( + this.clipboardHandler.addEventListener( 'input', function (event) { if (this.value === '') { @@ -4898,8 +4903,8 @@ CursorMorph.prototype.destroy = function () { this.target.drawNew(); this.target.changed(); } - if (this.hiddenText) { - document.body.removeChild(this.hiddenText); + if (this.clipboardHandler) { + document.body.removeChild(this.clipboardHandler); } CursorMorph.uber.destroy.call(this); }; diff --git a/morphic.txt b/morphic.txt index fb144c57..68280deb 100755 --- a/morphic.txt +++ b/morphic.txt @@ -9,7 +9,7 @@ Copyright (C) 2015 by Jens Mönig - this documentation last changed: Sep 23, 2015 + this documentation last changed: Dec 21, 2015 This file is part of Snap!. @@ -154,7 +154,7 @@ IV. open issues ---------------- - - clipboard support (copy & paste) + - clipboard support (copy & paste) for non-textual data - native (unscaled) high-resolution display support @@ -170,10 +170,11 @@ - Chrome for Windows - Chrome for Mac - Chrome for Android - - Safari for Windows + - Safari for Windows (deprecated) - safari for Mac - Safari for iOS (mobile) - IE for Windows + - Edge for Windows - Opera for Windows - Opera for Mac @@ -263,10 +264,11 @@ window.onload = function () { world = new WorldMorph( document.getElementById('world')); - setInterval(loop, 50); + loop(); }; function loop() { + requestAnimationFrame(loop); world.doOneCycle(); } @@ -310,10 +312,11 @@ document.getElementById('world1'), false); world2 = new WorldMorph( document.getElementById('world2'), false); - setInterval(loop, 50); + loop(); }; function loop() { + requestAnimationFrame(loop); world1.doOneCycle(); world2.doOneCycle(); } @@ -378,10 +381,11 @@ x = 0; y += 1; } - setInterval(loop, 50); + loop(); }; function loop() { + requestAnimationFrame(loop); world.doOneCycle(); } @@ -1044,5 +1048,6 @@ background texture handling, countless bug fixes and optimizations. Ian Reynolds contributed backspace key handling for Chrome. Davide Della Casa contributed performance optimizations for Firefox. + Jason N (@cyderize) contributed native copy & paste for text editing. - Jens Mönig