rilti.js | a small opinionated future forward front-end framework | Application Framework library
kandi X-RAY | rilti.js Summary
kandi X-RAY | rilti.js Summary
a small flavorful and unapologetic library built for the modern web. Feel free to fork or raise issues. Constructive criticism is always welcome.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of rilti.js
rilti.js Key Features
rilti.js Examples and Code Snippets
Community Discussions
Trending Discussions on rilti.js
QUESTION
The element containing a draggable
or moveable
handle can only start from the top
left
position, I have no idea how to adjust, calculate or correct the pixel values to make the draggable handle element start from say the bottom left like a normal graph would.
The position of the handle
is used to generate a range restricted value like a percentage value between 0-100
for both the x
and y
axis regardless of the element's pixel size.
It's a range-input or position picker of sorts intended for use in a color picker widget.
The color gradients change depending on the widget's relative position to the left, top or right of something, hence the picker or handle should adjust the starting point of it's range accordingly.
I'm using onpointermove
to get the x
and y
positions of the div.handle
and
adjust for the relative width
, height
, left
and top
, offsets of the parent element.
What I cannot figure out for the life of me is the math and code needed to allow the range input to track the position from an arbitrary corner, preferably bottom
left
.
Sorry for using a custom library but this example is mostly vanilla, at least the calculations which matter are.
...ANSWER
Answered 2018-Jul-15 at 13:44Another way to describe your issue is that your y-axis goes from 100 (technically, limitY) to 0 when it ought to go from 0 to 100. Therefore, we can slightly change your code to reverse this axis by fully calculating the y percentage, and then subracting it from 100. (ie, 100 - 80 = 20 or 100 - 35 - 65.) This will change the high values into low values and vice versa. Then, if we want to convert from percentage to pixel, we simply subtract it from 100 again to get our original flipped percentage (that you've already done all of the work for.)
The two lines changed are:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install rilti.js
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page