Skip to content

Commit e3d22d5

Browse files
committed
Merge pull request #11 from brewster1134/animation_boolean
animation boolean
2 parents 03fc069 + a1067ec commit e3d22d5

File tree

6 files changed

+54
-16
lines changed

6 files changed

+54
-16
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#### CHANGE LOG
22

3+
###### 1.0.4
4+
* allow passing a boolean for `goTo` method's animation argument
5+
36
###### 1.0.3
47
* improved sizing of viewport
58

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
sass (3.4.19)
4+
sass (3.4.22)
55

66
PLATFORMS
77
ruby
@@ -10,4 +10,4 @@ DEPENDENCIES
1010
sass (~> 3.4)
1111

1212
BUNDLED WITH
13-
1.10.6
13+
1.12.1

Newfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
sources:
33
default: ~/Code/ruby/new-tasks
44
name: Tiler
5-
version: 1.0.1
5+
version: 1.0.4
66
tasks:
77
changelog:
88
git:

lib/tiler.js

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/tiler_spec.coffee

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,25 @@ describe 'Tiler', ->
7979
it 'should add the active class', ->
8080
expect($('#go-to #tile-1').hasClass('foo-animation')).to.be.true
8181

82+
context 'when passing a boolean to active class', ->
83+
before ->
84+
$('#tile-1', '#go-to').data 'tiler-animation', 'goto-animate-1'
85+
$('#tile-2', '#go-to').data 'tiler-animation', 'goto-animate-2'
86+
87+
context 'when passing true', ->
88+
before ->
89+
$('#go-to').tiler('goTo', 2, true)
90+
91+
it 'should add the active class from the first tile', ->
92+
expect($('#go-to #tile-2').hasClass('goto-animate-2')).to.be.true
93+
94+
context 'when passing false', ->
95+
before ->
96+
$('#go-to').tiler('goTo', 1, false)
97+
98+
it 'should add the active class', ->
99+
expect($('#go-to #tile-1').hasClass('no-active-class')).to.be.true
100+
82101
describe 'refresh', ->
83102
newWidth = null
84103
newHeight = null

src/tiler.coffee

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# * tiler
33
# * https://github.com/brewster1134/tiler
44
# *
5-
# * @version 1.0.3
5+
# * @version 1.0.4
66
# * @author Ryan Brewster
77
# * Copyright (c) 2014
88
# * Licensed under the MIT license.
@@ -45,7 +45,7 @@
4545
@element.trigger 'tiler.refresh'
4646
@$enterTile?.trigger 'tiler.refresh'
4747

48-
goTo: (tile, animation) ->
48+
goTo: (tile, animation = true) ->
4949
# Find tile
5050
# Tile id as string
5151
$tile = if typeof tile == 'string'
@@ -70,14 +70,8 @@
7070
# Set the active tile id to the viewport
7171
@element.attr 'data-tiler-active-tile', @$enterTile.attr('id')
7272

73-
# Set tile class
74-
animationClass = if animation == false
75-
'no-active-class'
76-
else
77-
animation || @$enterTile.data('tiler-animation') || ''
78-
7973
# Manage css classes if an one is specified
80-
@_transitionCss animationClass
74+
@_transitionCss @_getAnimationClass animation
8175

8276
# Fire js events
8377
# Trigger on viewport
@@ -97,6 +91,16 @@
9791
#
9892
# PRIVATE METHODS
9993
#
94+
_getAnimationClass: (animation) ->
95+
# return explicitly passed animation
96+
return animation if typeof animation == 'string'
97+
98+
# use animaton from markup if true, and no-active-class for false
99+
if animation
100+
@$enterTile.data('tiler-animation') || ''
101+
else
102+
'no-active-class'
103+
100104
_transitionCss: (animationClass) ->
101105
enterTileId = @$tiles.index(@$enterTile, @$exitTile) + 1
102106

0 commit comments

Comments
 (0)