forked from FamousArchives/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
480 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
node_modules/ | ||
build.json | ||
build* |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* GenericSync | ||
* ------------ | ||
* | ||
* GenericSync combines multiple types of event handling | ||
* (e.g. touch, trackpad scrolling) into one standardized | ||
* interface for inclusion in widgets. TouchSync and ScrollSync | ||
* are enabled by default. | ||
* | ||
* In this example, we create a GenericSync that listens to | ||
* TouchSync, ScrollSync, and MouseSync and displays the data | ||
* it receives to the screen. | ||
* | ||
*/ | ||
define(function(require, exports, module) { | ||
var Engine = require("famous/core/Engine"); | ||
var GenericSync = require("famous/inputs/GenericSync"); | ||
var MouseSync = require("famous/inputs/MouseSync"); | ||
var TouchSync = require("famous/inputs/TouchSync"); | ||
var ScrollSync = require("famous/inputs/ScrollSync"); | ||
var Surface = require("famous/core/Surface"); | ||
var Accumulator = require("famous/inputs/Accumulator"); | ||
|
||
var mainContext = Engine.createContext(); | ||
|
||
var update = 0; | ||
var start = [0, 0]; | ||
|
||
GenericSync.register({ | ||
mouse : MouseSync, | ||
touch : TouchSync, | ||
scroll : ScrollSync | ||
}); | ||
|
||
var accumulator = new Accumulator(start); | ||
var genericSync = new GenericSync(['mouse', 'touch', 'scroll']); | ||
|
||
Engine.pipe(genericSync); | ||
genericSync.pipe(accumulator); | ||
|
||
var contentTemplate = function() { | ||
return "<div>Update Count: " + update + "</div>" + | ||
"<div>Accumulated distance: " + accumulator.get() + "</div>"; | ||
}; | ||
|
||
var surface = new Surface({ | ||
size: [undefined, undefined], | ||
classes: ['grey-bg'], | ||
content: contentTemplate() | ||
}); | ||
|
||
genericSync.on('start', function(){ | ||
accumulator.set(start); | ||
surface.setContent(contentTemplate()); | ||
}); | ||
|
||
genericSync.on("update", function() { | ||
update++; | ||
surface.setContent(contentTemplate()); | ||
}); | ||
|
||
mainContext.add(surface); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* GenericSync | ||
* ------------ | ||
* | ||
* GenericSync combines multiple types of event handling | ||
* (e.g. touch, trackpad scrolling) into one standardized | ||
* interface for inclusion in widgets. TouchSync and ScrollSync | ||
* are enabled by default. | ||
* | ||
* In this example, we create a GenericSync that listens to | ||
* TouchSync, ScrollSync, and MouseSync and displays the data | ||
* it receives to the screen. | ||
* | ||
*/ | ||
define(function(require, exports, module) { | ||
var Engine = require("famous/core/Engine"); | ||
var GenericSync = require("famous/inputs/GenericSync"); | ||
var MouseSync = require("famous/inputs/MouseSync"); | ||
var TouchSync = require("famous/inputs/TouchSync"); | ||
var ScrollSync = require("famous/inputs/ScrollSync"); | ||
var Surface = require("famous/core/Surface"); | ||
var Accumulator = require("famous/inputs/Accumulator"); | ||
|
||
var mainContext = Engine.createContext(); | ||
|
||
var update = 0; | ||
var start = 0; | ||
|
||
GenericSync.register({ | ||
mouse : MouseSync, | ||
touch : TouchSync, | ||
scroll : ScrollSync | ||
}); | ||
|
||
var accumulator = new Accumulator(start); | ||
|
||
var genericSync = new GenericSync({ | ||
mouse : { | ||
direction : GenericSync.DIRECTION_X, | ||
scale : 2 | ||
}, | ||
touch : {direction : GenericSync.DIRECTION_Y}, | ||
scroll : {direction : GenericSync.DIRECTION_Y} | ||
}); | ||
|
||
Engine.pipe(genericSync); | ||
genericSync.pipe(accumulator); | ||
|
||
var contentTemplate = function() { | ||
return "<div>Update Count: " + update + "</div>" + | ||
"<div>Accumulated distance: " + accumulator.get() + "</div>"; | ||
}; | ||
|
||
var surface = new Surface({ | ||
size: [undefined, undefined], | ||
classes: ['grey-bg'], | ||
content: contentTemplate() | ||
}); | ||
|
||
genericSync.on('start', function(){ | ||
accumulator.set(start); | ||
surface.setContent(contentTemplate()); | ||
}); | ||
|
||
genericSync.on("update", function() { | ||
update++; | ||
surface.setContent(contentTemplate()); | ||
}); | ||
|
||
mainContext.add(surface); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* MouseSync | ||
* ------------ | ||
* | ||
* Famo.us syncs default to track two-dimensional movement, | ||
* but can be passed as optional direction parameter to restrict | ||
* movement to a single axis. | ||
* | ||
* In this example, we create a MouseSync but only track the x-axis | ||
* changes on mouse drag. | ||
* | ||
*/ | ||
define(function(require, exports, module) { | ||
var Engine = require("famous/core/Engine"); | ||
var MouseSync = require("famous/inputs/MouseSync"); | ||
var Surface = require("famous/core/Surface"); | ||
var Accumulator = require("famous/inputs/Accumulator"); | ||
|
||
var mainContext = Engine.createContext(); | ||
|
||
var update = 0; | ||
|
||
var x = 0; | ||
var y = 0; | ||
var position = [x, y]; | ||
|
||
var mouseSync = new MouseSync(); | ||
var accumulator = new Accumulator(position); | ||
|
||
Engine.pipe(mouseSync); | ||
mouseSync.pipe(accumulator); | ||
|
||
var contentTemplate = function() { | ||
return "<div>Update Count: " + update + "</div>" + | ||
"<div>Accumulated distance: " + accumulator.get() + "</div>"; | ||
}; | ||
|
||
var surface = new Surface({ | ||
size: [undefined, undefined], | ||
classes: ["grey-bg"], | ||
content: contentTemplate() | ||
}); | ||
|
||
mouseSync.on("start", function() { | ||
accumulator.set([x,y]); | ||
surface.setContent(contentTemplate()); | ||
}); | ||
|
||
mouseSync.on("update", function() { | ||
update++; | ||
surface.setContent(contentTemplate()); | ||
}); | ||
|
||
mainContext.add(surface); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.