-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compare distance between cursor with absolute value. (#4295)
* fix with Math.abs * ok this works * added test * added test file * linting tests * wrong test
- Loading branch information
Showing
3 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(function(){ | ||
test('_getNewSelectionStartFromOffset end of line', function() { | ||
var iText = new fabric.IText('test need some word\nsecond line'); | ||
var index = 10; | ||
var jlen = 20; | ||
var selection = iText._getNewSelectionStartFromOffset({ y: 1, x: 1000 }, 500, 520, index, jlen); | ||
equal(selection, index, 'index value did not change'); | ||
}); | ||
test('_getNewSelectionStartFromOffset middle of line', function() { | ||
var iText = new fabric.IText('test need some word\nsecond line'); | ||
var index = 10; | ||
var jlen = 20; | ||
var selection = iText._getNewSelectionStartFromOffset({ y: 1, x: 519 }, 500, 520, index, jlen); | ||
equal(selection, index + 1, 'index value was moved to next char, since is very near'); | ||
}); | ||
test('_getNewSelectionStartFromOffset middle of line', function() { | ||
var iText = new fabric.IText('test need some word\nsecond line'); | ||
var index = 10; | ||
var jlen = 20; | ||
var selection = iText._getNewSelectionStartFromOffset({ y: 1, x: 502 }, 500, 520, index, jlen); | ||
equal(selection, index, 'index value was NOT moved to next char, since is very near to first one'); | ||
}); | ||
test('_getNewSelectionStartFromOffset middle of line', function() { | ||
var iText = new fabric.IText('test need some word\nsecond line'); | ||
var index = 10; | ||
var jlen = 10; | ||
var selection = iText._getNewSelectionStartFromOffset({ y: 1, x: 1000 }, 500, 520, index, jlen); | ||
equal(selection, index, 'index value was NOT moved to next char, since is already at end of text'); | ||
}); | ||
})(); |