vendor/assets/javascripts/holder.js in holder_rails-2.5.0 vs vendor/assets/javascripts/holder.js in holder_rails-2.5.2
- old
+ new
@@ -1,12 +1,12 @@
/*!
Holder - client side image placeholders
-Version 2.5.0+1qnmg
+Version 2.5.2+2mg3u
© 2015 Ivan Malopinsky - http://imsky.co
-Site: http://imsky.github.io/holder
+Site: http://holderjs.com
Issues: https://github.com/imsky/holder/issues
License: http://opensource.org/licenses/MIT
*/
/*!
@@ -315,30 +315,38 @@
//https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/requestAnimationFrame/polyfill-webkit.js
(function (global) {
// window.requestAnimationFrame
global.requestAnimationFrame = function (callback) {
return webkitRequestAnimationFrame(function () {
- callback(performance.now());
+ callback(global.performance.now());
});
};
-
+
// window.cancelAnimationFrame
global.cancelAnimationFrame = webkitCancelAnimationFrame;
}(this));
} else if (window.mozRequestAnimationFrame) {
//https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/requestAnimationFrame/polyfill-moz.js
(function (global) {
// window.requestAnimationFrame
global.requestAnimationFrame = function (callback) {
return mozRequestAnimationFrame(function () {
- callback(performance.now());
+ callback(global.performance.now());
});
};
// window.cancelAnimationFrame
global.cancelAnimationFrame = mozCancelAnimationFrame;
}(this));
+ } else {
+ (function (global) {
+ global.requestAnimationFrame = function (callback) {
+ return global.setTimeout(callback, 1000 / 60);
+ }
+
+ global.cancelAnimationFrame = global.clearTimeout;
+ })(this);
}
}
(function (global, factory) {
global.augment = factory();
}(this, function () {
@@ -378,11 +386,11 @@
(function(register, global, undefined) {
//Constants and definitions
var SVG_NS = 'http://www.w3.org/2000/svg';
var NODE_TYPE_COMMENT = 8;
var document = global.document;
- var version = '2.5.0';
+ var version = '2.5.2';
var generatorComment = '\n' +
'Created with Holder.js ' + version + '.\n' +
'Learn more at http://holderjs.com\n' +
'(c) 2012-2015 Ivan Malopinsky - http://imsky.co\n';
@@ -1122,11 +1130,12 @@
null,
null);
}
holderTextGroup.moveTo(
- (scene.width - holderTextGroup.width) / 2, (scene.height - holderTextGroup.height) / 2,
+ (scene.width - holderTextGroup.width) / 2,
+ (scene.height - holderTextGroup.height) / 2,
null);
//If the text exceeds vertical space, move it down so the first line is visible
if ((scene.height - holderTextGroup.height) / 2 < 0) {
holderTextGroup.moveTo(null, 0, null);
@@ -1136,11 +1145,12 @@
line = new Shape.Group('line0');
line.add(textNode);
holderTextGroup.add(line);
holderTextGroup.moveTo(
- (scene.width - tpdata.boundingBox.width) / 2, (scene.height - tpdata.boundingBox.height) / 2,
+ (scene.width - tpdata.boundingBox.width) / 2,
+ (scene.height - tpdata.boundingBox.height) / 2,
null);
}
//todo: renderlist
@@ -1374,12 +1384,11 @@
setAttr(stagingText, {
'y': htgProps.font.size,
'style': cssProps({
'font-weight': htgProps.font.weight,
'font-size': htgProps.font.size + htgProps.font.units,
- 'font-family': htgProps.font.family,
- 'dominant-baseline': 'middle'
+ 'font-family': htgProps.font.family
})
});
//Get bounding box for the whole string (total width and height)
stagingTextNode.nodeValue = htgProps.text;
@@ -1475,10 +1484,11 @@
//todo: create a reusable pool for textNodes, resize if more words present
return function(sceneGraph, renderSettings) {
var root = sceneGraph.root;
+
var holderURL = renderSettings.holderSettings.flags.holderURL;
var commentNode = document.createComment('\n' + 'Source URL: ' + holderURL + generatorComment);
initSVG(svg, root.properties.width, root.properties.height);
svg.insertBefore(commentNode, svg.firstChild);
@@ -1496,18 +1506,21 @@
});
var textGroup = root.children.holderTextGroup;
var tgProps = textGroup.properties;
var textGroupEl = newEl('g', SVG_NS);
+ var tpdata = textGroup.textPositionData;
svg.appendChild(textGroupEl);
+ textGroup.y += tpdata.boundingBox.height * 0.8;
+
for (var lineKey in textGroup.children) {
var line = textGroup.children[lineKey];
for (var wordKey in line.children) {
var word = line.children[wordKey];
var x = textGroup.x + line.x + word.x;
- var y = textGroup.y + line.y + word.y + (textGroup.properties.leading / 2);
+ var y = textGroup.y + line.y + word.y;
var textEl = newEl('text', SVG_NS);
var textNode = document.createTextNode(null);
setAttr(textEl, {
@@ -1515,11 +1528,10 @@
'y': y,
'style': cssProps({
'fill': tgProps.fill,
'font-weight': tgProps.font.weight,
'font-family': tgProps.font.family + ', monospace',
- 'font-size': tgProps.font.size + tgProps.font.units,
- 'dominant-baseline': 'central'
+ 'font-size': tgProps.font.size + tgProps.font.units
})
});
textNode.nodeValue = word.properties.text;
textEl.appendChild(textNode);
\ No newline at end of file