This is an automated email from the ASF dual-hosted git repository.
harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new fa7d424 Added pinValue
fa7d424 is described below
commit fa7d4244a2971bbf84d1bbcd52eaf507725340cb
Author: Harbs <[email protected]>
AuthorDate: Tue Jan 5 12:34:13 2021 +0200
Added pinValue
---
frameworks/projects/Core/src/main/royale/CoreClasses.as | 4 +++-
.../main/royale/org/apache/royale/utils/number/pinValue.as | 11 +++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/frameworks/projects/Core/src/main/royale/CoreClasses.as
b/frameworks/projects/Core/src/main/royale/CoreClasses.as
index 010dff5..27986b7 100644
--- a/frameworks/projects/Core/src/main/royale/CoreClasses.as
+++ b/frameworks/projects/Core/src/main/royale/CoreClasses.as
@@ -349,7 +349,9 @@ internal class CoreClasses
import org.apache.royale.utils.date.addMonths; addMonths;
import org.apache.royale.utils.date.addSeconds; addSeconds;
import org.apache.royale.utils.date.addYears; addYears;
-
+
+ import org.apache.royale.utils.number.pinValue; pinValue;
+
import org.apache.royale.utils.event.hasPlatformModifier;
hasPlatformModifier;
import org.apache.royale.utils.sendEvent; sendEvent;
import org.apache.royale.utils.sendBeadEvent; sendBeadEvent;
diff --git
a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/number/pinValue.as
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/number/pinValue.as
new file mode 100644
index 0000000..61c9e83
--- /dev/null
+++
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/number/pinValue.as
@@ -0,0 +1,11 @@
+package org.apache.royale.utils.number
+{
+ /**
+ * Pins the specified value between a specified maximum and minimum
bounds.
+ * If the value is outside the bounds, the minimum or maximum is
returned.
+ */
+ public function pinValue(value:Number, minimum:Number,
maximum:Number):Number
+ {
+ return Math.min(Math.max(value, minimum), maximum);
+ }
+}
\ No newline at end of file