add task:hide and task:show to ticket zoom

This commit is contained in:
Felix Niklas 2014-11-01 12:10:15 +01:00
parent f914658ff0
commit 1455348b7b
2 changed files with 43 additions and 15 deletions

View file

@ -40,6 +40,9 @@ class App.TicketZoom extends App.Controller
@delay( update, 1800, 'ticket-zoom-' + @ticket_id ) @delay( update, 1800, 'ticket-zoom-' + @ticket_id )
) )
@bind "task:hide", @onHide
@bind "task:show", @onShow
meta: => meta: =>
meta = meta =
url: @url() url: @url()
@ -69,6 +72,7 @@ class App.TicketZoom extends App.Controller
release: => release: =>
# nothing # nothing
@autosaveStop() @autosaveStop()
@scrollHeader.destroy() if @scrollHeader
fetch: (ticket_id, force) -> fetch: (ticket_id, force) ->
@ -385,23 +389,31 @@ class App.TicketZoom extends App.Controller
@userPopups() @userPopups()
@autosaveStart() @autosaveStart()
@scrollToBottom()
@bindScrollPageHeader() @bindScrollPageHeader()
@scrollToBottom() scrollToBottom: =>
scrollToBottom: ->
@main.scrollTop( @main.prop('scrollHeight') ) @main.scrollTop( @main.prop('scrollHeight') )
bindScrollPageHeader: -> bindScrollPageHeader: ->
pageHeader = @$('.page-header') pageHeader = @$('.page-header')
scrollHolder = pageHeader.scrollParent() scrollBody = @main.prop('scrollHeight') - @main.height()
scrollBody = scrollHolder.get(0).scrollHeight - scrollHolder.height()
if scrollBody > pageHeader.height() if scrollBody > pageHeader.height()
skrollr.init # TODO: recalculate the distance when adding a comment
@scrollHeader = skrollr.init
forceHeight: false forceHeight: false
holder: scrollHolder.get(0) holder: @main.get(0)
onShow: =>
if @scrollHeader
@scrollHeader.continue()
onHide: =>
if @scrollHeader
@scrollHeader.pause()
autosaveStop: => autosaveStop: =>
@autosaveLast = {} @autosaveLast = {}

View file

@ -7,6 +7,7 @@
* *
* Free to use under terms of MIT license * Free to use under terms of MIT license
*/ */
window.id = 0;
(function(window, document, undefined) { (function(window, document, undefined) {
'use strict'; 'use strict';
@ -19,7 +20,7 @@
}, },
//Main entry point. //Main entry point.
init: function(options) { init: function(options) {
return _instance || new Skrollr(options); new Skrollr(options);
}, },
VERSION: '0.6.26' VERSION: '0.6.26'
}; };
@ -232,6 +233,8 @@
_instance = this; _instance = this;
this.id = window.id++;
options = options || {}; options = options || {};
_constants = options.constants || {}; _constants = options.constants || {};
@ -308,17 +311,30 @@
} }
}); });
var requestAnimFrame = polyfillRAF();
//Let's go. //Let's go.
(function animloop(){ this.animloop();
_render();
_animFrame = requestAnimFrame(animloop);
}());
return _instance; return _instance;
} }
Skrollr.prototype.animloop = function() {
var requestAnimFrame = polyfillRAF();
_render();
// console.log("rendering", this.id);
if(!this.paused)
_animFrame = requestAnimFrame(_instance.animloop.bind(this));
}
Skrollr.prototype.pause = function() {
cancelAnimFrame(_animFrame);
this.paused = true;
}
Skrollr.prototype.continue = function() {
this.paused = false;
this.animloop();
}
/** /**
* (Re)parses some or all elements. * (Re)parses some or all elements.
*/ */
@ -616,7 +632,7 @@
if(_isMobile) { if(_isMobile) {
_mobileOffset = Math.min(Math.max(top, 0), _maxKeyFrame); _mobileOffset = Math.min(Math.max(top, 0), _maxKeyFrame);
} else { } else {
window.scrollTo(0, top); documentElement.scrollTop = top;
} }
return _instance; return _instance;