-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathImageSurface.js
68 lines (60 loc) · 1.88 KB
/
ImageSurface.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Owner: [email protected]
* @license MPL 2.0
* @copyright Famous Industries, Inc. 2014
*/
define(function(require, exports, module) {
var Surface = require('famous/core/Surface');
/**
* A surface containing image content.
* This extends the Surface class.
*
* @class ImageSurface
*
* @extends Surface
* @constructor
* @param {Object} [options] overrides of default options
*/
function ImageSurface(options) {
this._imageUrl = undefined;
Surface.apply(this, arguments);
}
ImageSurface.prototype = Object.create(Surface.prototype);
ImageSurface.prototype.constructor = ImageSurface;
ImageSurface.prototype.elementType = 'img';
ImageSurface.prototype.elementClass = 'famous-surface';
/**
* Set content URL. This will cause a re-rendering.
* @method setContent
* @param {string} imageUrl
*/
ImageSurface.prototype.setContent = function setContent(imageUrl) {
this._imageUrl = imageUrl;
this._contentDirty = true;
};
/**
* Place the document element that this component manages into the document.
*
* @private
* @method deploy
* @param {Node} target document parent of this container
*/
ImageSurface.prototype.deploy = function deploy(target) {
target.src = this._imageUrl || '';
};
/**
* Remove this component and contained content from the document
*
* @private
* @method recall
*
* @param {Node} target node to which the component was deployed
*/
ImageSurface.prototype.recall = function recall(target) {
target.src = '';
};
module.exports = ImageSurface;
});