sajaniemi_variable_dataset_large / pool /shard002 /JavaScript /0012769_rcd-jsfwk-material-progress.js
Download pool/shard002/JavaScript/0012769_rcd-jsfwk-material-progress.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard002/JavaScript/0012769_rcd-jsfwk-material-progress.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard002/JavaScript/0012769_rcd-jsfwk-material-progress.js
-
curl -L -o 0012769_rcd-jsfwk-material-progress.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard002/JavaScript/0012769_rcd-jsfwk-material-progress.js
1.5 kB
| class RcdLinearProgressIndicator extends RcdHtmlElement { | |
| constructor(params) { | |
| super('svg', 'http://www.w3.org/2000/svg'); | |
| this.width = params.width; | |
| this.height = params.height; | |
| this.backgroundLine = new RcdHtmlElement('line', this.namespaceURI) | |
| .addClass('rcd-material-linear-background-line') | |
| .setAttributeNS(null, 'x1', '0') | |
| .setAttributeNS(null, 'y1', '0') | |
| .setAttributeNS(null, 'x2', this.width) | |
| .setAttributeNS(null, 'y2', '0'); | |
| this.line = new RcdHtmlElement('line', this.namespaceURI) | |
| .addClass('rcd-material-linear-line') | |
| .setAttributeNS(null, 'stroke-dasharray', this.width + ' ' + this.width ) | |
| .setAttributeNS(null, 'stroke-dashoffset', '100%' ) | |
| .setAttributeNS(null, 'x1', '0') | |
| .setAttributeNS(null, 'y1', '0') | |
| .setAttributeNS(null, 'x2', this.width) | |
| .setAttributeNS(null, 'y2', '0'); | |
| } | |
| init() { | |
| return super.init() | |
| .addClass('rcd-material-linear-progress') | |
| .setAttributeNS(null, 'width', this.width) | |
| .setAttributeNS(null, 'height', this.height) | |
| .addChild(this.backgroundLine) | |
| .addChild(this.line); | |
| } | |
| setProgress(progress) { | |
| const dashoffset = Math.ceil(this.width - (progress * this.width)); | |
| this.line.setAttributeNS(null, 'stroke-dashoffset', dashoffset); | |
| return this; | |
| } | |
| } |