Permalink
Browse files

Merge branch 'master' into keyframe

Conflicts:
	Makefile
	build/framer.js
	src/views/view.coffee
	template/framer.js
  • Loading branch information...
Koen Bok
Koen Bok committed Mar 18, 2013
2 parents 98ca654 + 82d798c commit e73e07a9dba840d71d9f6ae9bf0c467bec359eb3
Showing with 9,850 additions and 11 deletions.
  1. +4 −1 .gitignore
  2. +9 −1 Makefile
  3. +30 −3 build/framer.js
  4. +85 −0 src/gestures.coffee
  5. +24 −3 src/views/view.coffee
  6. +30 −3 template/framer.js
  7. +23 −0 test/index.html
  8. +1 −0 test/init.coffee
  9. +62 −0 test/src/view.coffee
  10. +3,996 −0 test/vendor/chai.js
  11. +241 −0 test/vendor/mocha.css
  12. +5,341 −0 test/vendor/mocha.js
  13. +4 −0 test/vendor/mocha.opts
View
@@ -1,2 +1,5 @@
.DS_Store
node_modules
node_modules
test/init.js
test/lib/framer.js
*.swp
View
@@ -11,10 +11,18 @@ build:
rm build/framer.build.js
cp build/framer.js template/framer.js
test:
make
mkdir -p test/lib
cp build/framer.js test/lib/framer.js
./node_modules/browserify/bin/cmd.js test/init.coffee -o test/init.js
open test/index.html
clean:
rm -rf dist
lint:
./node_modules/coffeelint/bin/coffeelint -f lint.config.json -r src
.PHONY: build clean lint
.PHONY: build clean lint test
View
@@ -1,6 +1,6 @@
// Framer 0.5.0-30-g37cd9ec (c) 2013 Koen Bok
// Framer 0.5.0-31-g98ca654 (c) 2013 Koen Bok
window.FramerVersion = "0.5.0-30-g37cd9ec";
window.FramerVersion = "0.5.0-31-g98ca654";
(function(){var require = function (file, cwd) {
@@ -2339,6 +2339,32 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam
}
});
View.define("index", {
get: function() {
return this.style['z-index'] || 0;
},
set: function(value) {
this.style['z-index'] = value;
return this.emit("change:index");
}
});
View.prototype.placeBefore = function(view) {
return this.index = view.index + 1;
};
View.prototype.placeBehind = function(view) {
return this.index = view.index - 1;
};
View.prototype.switchPlaces = function(view) {
var indexA, indexB;
indexA = this.index;
indexB = view.index;
view.index = indexA;
return this.index = indexB;
};
View.prototype.animate = function(args, callback) {
var animation;
args.view = this;
@@ -2466,7 +2492,8 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam
html: null,
"class": "",
superView: null,
visible: true
visible: true,
index: 0
});
View.Views = [];
View
@@ -0,0 +1,85 @@
# Adapted from http://alxgbsn.co.uk/
class Gesture
Gestures = ["tap", "tapend"]
ListenEvents = ["touchmove", "touchend", "touchcancel", "mousemove", "mouseup"]
MoveCancelAllowance = 10
constructor: (@element, @gesture, @callback) ->
@moved = false
@startX = 0
@startY = 0
@hasTouchEventOccured = false
@element.addEventListener "touchstart", @handleEvent, false
@element.addEventListener "mousedown", @handleEvent, false
start: (e) ->
@hasTouchEventOccured = true if e.type is "touchstart"
@moved = false
@startX = (if e.type is "touchstart" then e.touches[0].clientX else e.clientX)
@startY = (if e.type is "touchstart" then e.touches[0].clientY else e.clientY)
for event in @ListenEvents
@element.addEventListener event, @handleEvent, false
move: (e) ->
x = (if e.type is "touchmove" then e.touches[0].clientX else e.clientX)
y = (if e.type is "touchmove" then e.touches[0].clientY else e.clientY)
#if finger moves more than 10px flag to cancel
p = @MoveCancelAllowance
if Math.abs(x - @startX) > p or Math.abs(y - @startY) > p
@moved = true
end: (e) ->
# evt = undefined
# # Weird situation where
# if @hasTouchEventOccured and e.type is "mouseup"
# e.preventDefault()
# e.stopPropagation()
# @hasTouchEventOccured = false
# return
unless @moved
evt = document.createEvent("Event")
evt.initEvent "tap", true, true
e.target.dispatchEvent evt
for event in @ListenEvents
@element.removeEventListener event, @handleEvent, false
cancel: (e) ->
@moved = false
@startX = 0
@startY = 0
for event in @ListenEvents
@element.removeEventListener event, @handleEvent, false
handleEvent: (e) ->
switch e.type
when "touchstart"
@start e
when "touchmove"
@move e
when "touchend"
@end e
when "touchcancel"
@cancel e
when "mousedown"
@start e
when "mousemove"
@move e
when "mouseup"
@end e
View
@@ -112,19 +112,20 @@ class View extends Frame
set: (value) ->
@_matrix.x = value
@_matrix = @_matrix
@emit "change:x"
@emit "change:frame"
@define "y"
get: -> @_matrix.y
set: (value) ->
@_matrix.y = value
@_matrix = @_matrix
@emit "change:y"
@emit "change:frame"
@define "z"
get: -> @_matrix.z
set: (value) ->
@@ -134,7 +135,6 @@ class View extends Frame
@emit "change:z"
@emit "change:frame"
#############################################################################
## Scale
@@ -304,7 +304,27 @@ class View extends Frame
@define "subViews"
get: -> @_subViews
#############################################################################
## Indexes
@define "index"
get: -> @style['z-index'] or 0
set: (value) ->
@style['z-index'] = value
@emit "change:index"
placeBefore: (view) ->
@index = view.index + 1
placeBehind: (view) ->
@index = view.index - 1
switchPlaces: (view) ->
indexA = @index
indexB = view.index
view.index = indexA
@index = indexB
#############################################################################
## Animation
@@ -414,6 +434,7 @@ View.Properties = utils.extend Frame.Properties,
class: ""
superView: null
visible: true
index: 0
View.Views = []
View
@@ -1,6 +1,6 @@
// Framer 0.5.0-30-g37cd9ec (c) 2013 Koen Bok
// Framer 0.5.0-31-g98ca654 (c) 2013 Koen Bok
window.FramerVersion = "0.5.0-30-g37cd9ec";
window.FramerVersion = "0.5.0-31-g98ca654";
(function(){var require = function (file, cwd) {
@@ -2339,6 +2339,32 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam
}
});
View.define("index", {
get: function() {
return this.style['z-index'] || 0;
},
set: function(value) {
this.style['z-index'] = value;
return this.emit("change:index");
}
});
View.prototype.placeBefore = function(view) {
return this.index = view.index + 1;
};
View.prototype.placeBehind = function(view) {
return this.index = view.index - 1;
};
View.prototype.switchPlaces = function(view) {
var indexA, indexB;
indexA = this.index;
indexB = view.index;
view.index = indexA;
return this.index = indexB;
};
View.prototype.animate = function(args, callback) {
var animation;
args.view = this;
@@ -2466,7 +2492,8 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam
html: null,
"class": "",
superView: null,
visible: true
visible: true,
index: 0
});
View.Views = [];
View
@@ -0,0 +1,23 @@
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="vendor/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="vendor/mocha.js"></script>
<script src="vendor/chai.js"></script>
<script src="lib/framer.js"></script>
<script>
chai.should()
mocha.setup('bdd')
$(function() {
mocha.run()
})
</script>
<script src="init.js"></script>
</body>
</html>
View
@@ -0,0 +1 @@
{ViewTest} = require './src/view'
View
@@ -0,0 +1,62 @@
describe "View", ->
view = new View()
describe "Geometry", ->
it "should set x", ->
view.x = 100
view.x.should.equal 100
it "should set y", ->
view.y = 100
view.y.should.equal 100
it "should set width", ->
view.width = 100
view.width.should.equal 100
it "should set height", ->
view.height = 100
view.height.should.equal 100
it "should set maxX", ->
view.maxX = 300
view.minX.should.equal 200
view.midX.should.equal 250
view.maxX.should.equal 300
it "should set maxY", ->
view.maxY = 300
view.minY.should.equal 200
view.midY.should.equal 250
view.maxY.should.equal 300
it "should set frame", ->
frame = {x:200, y:200, width:200, height:200}
view.frame = frame
# view.frame.should.eql frame
view.x.should.equal frame.x
view.y.should.equal frame.y
view.width.should.equal frame.width
view.height.should.equal frame.height
describe "Hierarchy", ->
describe "Layering", ->
describe "Styling", ->
describe "HTML", ->
it "should allow classes to be added", ->
view.addClass('foo')
view.addClass('bar')
view.class.should.equal 'uilayer textureBacked foo bar'
# it "should allow classes to be removed", ->
# view.addClass('foo')
# view.addClass('bar')
# view.removeClass('bar')
# view.class.should.equal [ 'uilayer', 'textureBackend', 'foo' ]
Oops, something went wrong.

0 comments on commit e73e07a

Please sign in to comment.