/**
 * Generated by Apache Royale Compiler from org\apache\royale\html\beads\InfiniteVScroller.as
 * org.apache.royale.html.beads.InfiniteVScroller
 *
 * @fileoverview
 *
 * @suppress {checkTypes|accessControls}
 */

goog.provide('org.apache.royale.html.beads.InfiniteVScroller');

goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.core.IUIBase');
goog.require('org.apache.royale.events.EventDispatcher');
goog.require('org.apache.royale.core.IBead');
goog.require('org.apache.royale.utils.Language');



/**
 * Constructor.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.3
 * @constructor
 * @extends {org.apache.royale.events.EventDispatcher}
 * @implements {org.apache.royale.core.IBead}
 */
org.apache.royale.html.beads.InfiniteVScroller = function() {
  org.apache.royale.html.beads.InfiniteVScroller.base(this, 'constructor');
};
goog.inherits(org.apache.royale.html.beads.InfiniteVScroller, org.apache.royale.events.EventDispatcher);


/**
 * Prevent renaming of class. Needed for reflection.
 */
goog.exportSymbol('org.apache.royale.html.beads.InfiniteVScroller', org.apache.royale.html.beads.InfiniteVScroller);


/**
 * @protected
 * @type {org.apache.royale.core.IStrand}
 */
org.apache.royale.html.beads.InfiniteVScroller.prototype._strand;


/**
 * @private
 * @type {number}
 */
org.apache.royale.html.beads.InfiniteVScroller.prototype.org_apache_royale_html_beads_InfiniteVScroller__offset = 0;


/**
 * @private
 * @type {number}
 */
org.apache.royale.html.beads.InfiniteVScroller.prototype.org_apache_royale_html_beads_InfiniteVScroller__interval = 1000;


/**
 * @private
 * @type {number}
 */
org.apache.royale.html.beads.InfiniteVScroller.prototype.org_apache_royale_html_beads_InfiniteVScroller_lastTime = 0;


/**
 * @private
 * @type {number}
 */
org.apache.royale.html.beads.InfiniteVScroller.prototype.org_apache_royale_html_beads_InfiniteVScroller_lastTop = 0;


/**
 * @private
 * @param {Object} ev
 */
org.apache.royale.html.beads.InfiniteVScroller.prototype.org_apache_royale_html_beads_InfiniteVScroller_handleScroll = function(ev) {
  var /** @type {HTMLElement} */ elem = this.org_apache_royale_html_beads_InfiniteVScroller_host.positioner;
  var /** @type {number} */ top = elem.scrollTop;
  if (top < this.org_apache_royale_html_beads_InfiniteVScroller_lastTop) {
    this.org_apache_royale_html_beads_InfiniteVScroller_lastTop = top;
    return;
  }
  this.org_apache_royale_html_beads_InfiniteVScroller_lastTop = top;
  if (elem.offsetHeight + top >= elem.scrollHeight - this.org_apache_royale_html_beads_InfiniteVScroller__offset) {
    var /** @type {number} */ time = new Date().getTime();
    if (time - this.org_apache_royale_html_beads_InfiniteVScroller_lastTime < this.org_apache_royale_html_beads_InfiniteVScroller__interval)
      return;
    this.org_apache_royale_html_beads_InfiniteVScroller_lastTime = time;
    this.dispatchEvent(new Event("scrollEnd"));
  }
};


org.apache.royale.html.beads.InfiniteVScroller.prototype.get__org_apache_royale_html_beads_InfiniteVScroller_host = function() {
  return this._strand;
};


org.apache.royale.html.beads.InfiniteVScroller.prototype.get__offset = function() {
  return this.org_apache_royale_html_beads_InfiniteVScroller__offset;
};


org.apache.royale.html.beads.InfiniteVScroller.prototype.set__offset = function(value) {
  this.org_apache_royale_html_beads_InfiniteVScroller__offset = value;
};


org.apache.royale.html.beads.InfiniteVScroller.prototype.get__interval = function() {
  return this.org_apache_royale_html_beads_InfiniteVScroller__interval;
};


org.apache.royale.html.beads.InfiniteVScroller.prototype.set__interval = function(value) {
  this.org_apache_royale_html_beads_InfiniteVScroller__interval = value;
};


org.apache.royale.html.beads.InfiniteVScroller.prototype.set__strand = function(value) {
  this._strand = value;
  this.org_apache_royale_html_beads_InfiniteVScroller_host.positioner.addEventListener("scroll", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_InfiniteVScroller_handleScroll, this, 'handleScroll'));
};


Object.defineProperties(org.apache.royale.html.beads.InfiniteVScroller.prototype, /** @lends {org.apache.royale.html.beads.InfiniteVScroller.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IUIBase} */
org_apache_royale_html_beads_InfiniteVScroller_host: {
get: org.apache.royale.html.beads.InfiniteVScroller.prototype.get__org_apache_royale_html_beads_InfiniteVScroller_host},
/**
  * @export
  * @type {number} */
offset: {
get: org.apache.royale.html.beads.InfiniteVScroller.prototype.get__offset,
set: org.apache.royale.html.beads.InfiniteVScroller.prototype.set__offset},
/**
  * @export
  * @type {number} */
interval: {
get: org.apache.royale.html.beads.InfiniteVScroller.prototype.get__interval,
set: org.apache.royale.html.beads.InfiniteVScroller.prototype.set__interval},
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.html.beads.InfiniteVScroller.prototype.set__strand}}
);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.royale.html.beads.InfiniteVScroller.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'InfiniteVScroller', qName: 'org.apache.royale.html.beads.InfiniteVScroller', kind: 'class' }], interfaces: [org.apache.royale.core.IBead] };



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.beads.InfiniteVScroller.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'offset': { type: 'Number', access: 'readwrite', declaredBy: 'org.apache.royale.html.beads.InfiniteVScroller'},
        'interval': { type: 'int', access: 'readwrite', declaredBy: 'org.apache.royale.html.beads.InfiniteVScroller'},
        'strand': { type: 'org.apache.royale.core.IStrand', access: 'writeonly', declaredBy: 'org.apache.royale.html.beads.InfiniteVScroller'}
      };
    },
    methods: function () {
      return {
        'InfiniteVScroller': { type: '', declaredBy: 'org.apache.royale.html.beads.InfiniteVScroller'}
      };
    },
    metadata: function () { return [  ]; }
  };
};