MCPcopy Index your code
hub / github.com/angular-dragdrop/angular-dragdrop / fitString

Function fitString

draganddrop.js:434–444  ·  view source on GitHub ↗
(canvas, text, config)

Source from the content-addressed store, hash-verified

432 var ELLIPSIS = '…';
433
434 function fitString(canvas, text, config) {
435 var width = canvas.measureText(text).width;
436 if (width < config.width) {
437 return text;
438 }
439 while (width + config.padding > config.width) {
440 text = text.substring(0, text.length - 1);
441 width = canvas.measureText(text + ELLIPSIS).width;
442 }
443 return text + ELLIPSIS;
444 }
445
446 this.generate = function(text, options) {
447 var config = angular.extend({}, defaultConfig, options || {});

Callers 1

draganddrop.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected