Skip to content

Commit

Permalink
fixed fps bug
Browse files Browse the repository at this point in the history
  • Loading branch information
stevewirts committed Jun 25, 2015
1 parent f9ec0d7 commit 9684cce
Show file tree
Hide file tree
Showing 11 changed files with 227 additions and 18 deletions.
4 changes: 3 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ var files = {
polymerjs: [
'polymer/js/**/*.js',
'test/**/*.js',
'js/**/*.js'
'js/**/*.js',
'!polymer/js/bitset.min.js',
'!polymer/js/data.js'
],

polymercss: [
Expand Down
4 changes: 3 additions & 1 deletion demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ <h3>fin-hypergrid-behavior-gol</h3> This element is another custom Polymer web c
var lnfOverrides = {
scrollbarHoverOver: 'visible',
scrollbarHoverOff: 'visible',
scrollingEnabled: true
scrollingEnabled: true,
repaintIntervalRate: 0,
//repaintImmediately: true
};
inMemoryGrid.addProperties(lnfOverrides);

Expand Down
126 changes: 126 additions & 0 deletions docs/module-._fin-hypergrid.html
Original file line number Diff line number Diff line change
Expand Up @@ -13826,6 +13826,132 @@ <h4 class="name" id="popMouseDown"><span class="type-signature"></span>popMouseD















</dl>





















<h4 class="name" id="refreshProperties"><span class="type-signature"></span>refreshProperties<span class="signature">(properties)</span><span class="type-signature"></span></h4>





<div class="description">
<p>utility function to push out properties if we change them</p>
</div>









<h5>Parameters:</h5>


<table class="params">
<thead>
<tr>

<th>Name</th>


<th>Type</th>





<th class="last">Description</th>
</tr>
</thead>

<tbody>


<tr>

<td class="name"><code>properties</code></td>


<td class="type">


<span class="param-type">object</span>



</td>





<td class="description last"><p>an object of various key value pairs</p></td>
</tr>


</tbody>
</table>






<dl class="details">























Expand Down
52 changes: 40 additions & 12 deletions fin-hypergrid.dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -12990,14 +12990,6 @@
*/
ctx: null,

/** .
* fps is how many times a second we check the repaint flag for redrawing
*
* @property fps
* @type Number
*/
fps: null,

/** .
* mouseLocation is the current position of the mouse pointer
*
Expand Down Expand Up @@ -13155,8 +13147,6 @@
this.buffer = document.createElement('canvas');
this.bufferCTX = this.buffer.getContext('2d');

this.fps = this.getAttribute('fps') || 60;

this.mouseLocation = this.g.point.create(-1, -1);
this.dragstart = this.g.point.create(-1, -1);
//this.origin = this.g.point.create(0, 0);
Expand Down Expand Up @@ -13236,6 +13226,21 @@
return this.getAttribute('bitblit') !== 'false';
},

/**
* .
* .
* return if I have the bitblit attribute set
*
* @method useBitBlit()
*/
getFPS: function() {
var fps = this.getAttribute('fps');
if (fps === 0 || !fps) {
return 0;
}
return parseInt(fps);
},

/**
* .
* .
Expand Down Expand Up @@ -13269,7 +13274,7 @@
},

tickPaint: function(now) {
var interval = 1000 / this.fps;
var interval = 1000 / this.getFPS();
var lastRepaintTime = 0;
this.checkSizeCounter++;
if (this.checkSizeCounter < 3 || (this.checkSizeCounter % 45) === 0) {
Expand Down Expand Up @@ -13914,7 +13919,11 @@
* @method repaint()
*/
repaint: function() {
var fps = this.getFPS();
this.repaintNow = true;
if (fps === 0) {
this.paintNow();
}
},

/**
Expand Down Expand Up @@ -32094,6 +32103,24 @@
this.lnfProperties[key] = properties[key];
}
}
this.refreshProperties();
},

/**
* @function
* @description
utility function to push out properties if we change them
* @param {object} properties - an object of various key value pairs
* @instance
*/

refreshProperties: function() {
var interval = this.resolveProperty('repaintIntervalRate');
var useBitBlit = this.resolveProperty('useBitBlit');
this.canvas = this.shadowRoot.querySelector('fin-canvas');
interval = interval === undefined ? 15 : interval;
this.canvas.setAttribute('fps', interval);
this.canvas.setAttribute('bitblit', useBitBlit === true);
},

/**
Expand Down Expand Up @@ -32620,7 +32647,8 @@
var interval = this.resolveProperty('repaintIntervalRate');
var useBitBlit = this.resolveProperty('useBitBlit');
this.canvas = this.shadowRoot.querySelector('fin-canvas');
this.canvas.setAttribute('fps', interval || 15);
interval = interval === undefined ? 15 : interval;
this.canvas.setAttribute('fps', interval);
this.canvas.setAttribute('bitblit', useBitBlit === true);

//this.shadowRoot.appendChild(domCanvas);
Expand Down
6 changes: 3 additions & 3 deletions fin-hypergrid.min.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
'./polymer/html/behaviors/fin-hypergrid-behavior-q.html',
'./polymer/html/behaviors/fin-hypergrid-behavior-qtree.html',
'./polymer/html/behaviors/fin-hypergrid-behavior-web-worker.html',
'./polymer/html/bitset.min.html',
'./polymer/html/cell-editors/fin-hypergrid-cell-editor-base.html',
'./polymer/html/cell-editors/fin-hypergrid-cell-editor-choice.html',
'./polymer/html/cell-editors/fin-hypergrid-cell-editor-color.html',
Expand Down
4 changes: 4 additions & 0 deletions polymer/css/bitset.min.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:host {
display: block;
position: relative;
}
10 changes: 10 additions & 0 deletions polymer/html/bitset.min.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!--
The `bitset.min` element is a custom Polymer web component
@element bitset.min
-->
<polymer-element name="bitset.min" attributes="">
<template>
<link rel="stylesheet" type="text/css" href="../../polymer/css/bitset.min.css">
</template>
<script src="../../polymer/js/bitset.min.js"></script>
</polymer-element>
21 changes: 20 additions & 1 deletion polymer/js/fin-hypergrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,24 @@
this.lnfProperties[key] = properties[key];
}
}
this.refreshProperties();
},

/**
* @function
* @description
utility function to push out properties if we change them
* @param {object} properties - an object of various key value pairs
* @instance
*/

refreshProperties: function() {
var interval = this.resolveProperty('repaintIntervalRate');
var useBitBlit = this.resolveProperty('useBitBlit');
this.canvas = this.shadowRoot.querySelector('fin-canvas');
interval = interval === undefined ? 15 : interval;
this.canvas.setAttribute('fps', interval);
this.canvas.setAttribute('bitblit', useBitBlit === true);
},

/**
Expand Down Expand Up @@ -1097,7 +1115,8 @@
var interval = this.resolveProperty('repaintIntervalRate');
var useBitBlit = this.resolveProperty('useBitBlit');
this.canvas = this.shadowRoot.querySelector('fin-canvas');
this.canvas.setAttribute('fps', interval || 15);
interval = interval === undefined ? 15 : interval;
this.canvas.setAttribute('fps', interval);
this.canvas.setAttribute('bitblit', useBitBlit === true);

//this.shadowRoot.appendChild(domCanvas);
Expand Down
16 changes: 16 additions & 0 deletions test/bitset.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* globals describe, it, assert */

'use strict';

var customElement = document.querySelector('bitset.min');

describe('<bitset.min>', function() {

describe('bitset.min.js', function() {
it('should have real tests filled out', function() {
assert.equal(customElement, customElement);
});

});

});
1 change: 1 addition & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'behaviors/fin-hypergrid-behavior-q.js',
'behaviors/fin-hypergrid-behavior-qtree.js',
'behaviors/fin-hypergrid-behavior-web-worker.js',
'bitset.min.js',
'cell-editors/fin-hypergrid-cell-editor-base.js',
'cell-editors/fin-hypergrid-cell-editor-choice.js',
'cell-editors/fin-hypergrid-cell-editor-color.js',
Expand Down

0 comments on commit 9684cce

Please sign in to comment.