Skip to content

Instantly share code, notes, and snippets.

@hansemannn
Last active August 25, 2017 03:13
Show Gist options
  • Save hansemannn/1e65a4d2b7371576755537d66647345f to your computer and use it in GitHub Desktop.
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+
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