Last active
August 25, 2017 03:13
-
-
Save hansemannn/1e65a4d2b7371576755537d66647345f to your computer and use it in GitHub Desktop.
Haptic Feedback on iOS 10, iPhone 7 and Titanium SDK 6.0.0+
This file contains hidden or 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
var win = Ti.UI.createWindow({ | |
backgroundColor: "#fff" | |
}); | |
var slider = Ti.UI.createSlider({ | |
min: 0, | |
max: 100, | |
width: 200 | |
}); | |
var feedback = Ti.UI.iOS.createFeedbackGenerator({ | |
type: Ti.UI.iOS.FEEDBACK_GENERATOR_TYPE_SELECTION | |
}); | |
// Do a haptic feedback every 25 % | |
slider.addEventListener("change", function(e) { | |
if (e.value % 25 == 0 && [slider.min, slider.max].indexOf(e.value) === -1) { | |
feedback.prepare(); | |
feedback.selectionChanged(); | |
} | |
}); | |
win.add(slider); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment