mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
js mode example cleanups
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
|
||||
// wait for document to load ...
|
||||
window.onload = function () {
|
||||
tryLinkSketch();
|
||||
}
|
||||
|
||||
// try and find the sketch
|
||||
function tryLinkSketch() {
|
||||
var sketchId = "wordDroppings";
|
||||
var sketch = Processing.getInstanceById(sketchId);
|
||||
var sketch = Processing.instances[0];
|
||||
if ( sketch == undefined )
|
||||
return setTimeout(tryLinkSketch, 200); /*try again later*/
|
||||
setTimeout(tryLinkSketch, 200); /*try again later*/
|
||||
else {
|
||||
initDragDrop(sketch);
|
||||
}
|
||||
}
|
||||
|
||||
// initialize DnD, add event listeners
|
||||
function initDragDrop ( sketch ) {
|
||||
var target = sketch.externals.canvas;
|
||||
var targetPosition = getElementPosition(target);
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
* <div>Drag</div> <div>us</div> <div>to</div> <div>your</div> <div>sketch</div>
|
||||
* </div>
|
||||
* <style>.draggables div{display: inline-block;background:white;color: black;padding: 10px;}</style>
|
||||
* <br />
|
||||
* (Opera currently not supported …)
|
||||
*/
|
||||
|
||||
color normalColor;
|
||||
@@ -60,6 +58,9 @@ void draw ()
|
||||
text( message, cx+7.5, cy+2.5 );
|
||||
}
|
||||
|
||||
// the following events are not part of Processing API. they
|
||||
// are being called from JavaScript, see ".js" tab
|
||||
|
||||
void dragEnter ()
|
||||
{
|
||||
currentColor = dragColor;
|
||||
|
||||
Reference in New Issue
Block a user