In reveal.js, is there a standard way to make left-click advance to the next slide? - reveal.js

In Powerpoint, clicking the left mouse button advances to the next slide. In reveal.js, it is done using the keyboard. Is it possible to configure reveal.js to advance to the next slide also when clicking the mouse button?

It looks like you can add a click event to the entire slide and and check the button for the event.
window.addEventListener("mousedown", handleClick, false);
window.addEventListener("contextmenu", function(e) { e.preventDefault(); }, false);
function handleClick(e) {
e.preventDefault();
if(e.button === 0) Reveal.next();
if(e.button === 2) Reveal.prev();
}
If you're worried about links on the page not being clickable you can check the target of the event. If it's a link, don't proceed to the next slide.
This site could be useful and has a more in depth explanation. It's where the above code is from.

Related

jQuery tabs + scroll to content simultaneously

This is driving me a little crazy as I just can't get it to work :(!
I have jQuery tabs set-up as follows (all working) :
$(".tabs_area" ).tabs({
fx: { duration: 'slow', opacity: 'toggle' }
});
I then have a scroll to anchor focus mechanism (again works fine in terms of the function itself) :
$('.tabs_area li a').bind('click',function(event){
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 500,'easeInOutExpo');
event.preventDefault();
});
My problem is that sadly they won't work simultaneously. When I click the tab, it correctly displays the corresponding tab content BUT it doesn't scroll you to the start of this content. You have to click the tab again for it to then do the scroll to the content, which isn't good.
Sadly the reason I need is that I am using this on a mobile website, and when you click the tab, although it does actually change the content, it is bellow the tabs menu, and therefore below the visible area of the screen, hence why I want it to swap the content then scroll you down to this so you can see it, and of course with one click only.
So I think I need to combine the scroll functionality within the tabs set-up code... somehow... as a callback or something... but I just keep breaking it :(!!
Any help would be so much appreciated.
Thanks in advance,
TJ
Why don't you use the show option for jQuery Tabs?
Seems to do what you wish to do.
Check the solution
$(".tabs_area" ).tabs({
show: function(e,ui){
$('html, body').stop().animate({
scrollTop: $(ui.tab.getAttribute('href')).offset().top
}, 500,'easeInOutExpo');
}
});

How to target the close button in a dialog window frame?

I am using a jQuery dialog and I would like to add some functionality to the close button in the upper right and corner of the dialog frame. Can I accomplish this by simply adding a close function to the dialog without it affecting the cancel button contained within the dialog? Meaning the cancel button obviously closes the dialog and performs its own function but the close button in the dialog frame needs to do something else. Hopefully I have explained that clearly enough.
If you are using the buttons options within the dialog, and one of them is Cancel, then yes. You can obviously create your own function for the Cancel button and then a seperate one with the close event. Just to be safe, you'll probably want to include preventDefault() in the function for your Cancel button.
$('#dialog').dialog({
buttons: {
"Ok" : function() {
//perform whatever
},
"Cancel" : function(e) {
e.preventDefault();
//perform whatever
},
close: function() {
// perform special CLOSE function
}
});
Actually I used this method below to accomplish this. It seems to work just fine so I don't know if there are any drawbacks with going this way. Here is the code:
$("#dialog").dialog({
...dialog code goes here...
}).bind('dialogclose', function(event, ui) {
... dialog close code goes here...
});
I suppose the answer above is better as it is clearer and cleaner implementation.

Jquery Mobile 1.3 slider conflicts with panel

I am trying to set up a JQuery Mobile 1.3 site that uses a panel and a slider.
Problem is, that using the slider triggers the panel, which opens on a "swiperight" event, as I am moving the slider to the right. The slider will be for pagination, the panel for a menu.
Code here:
http://jsfiddle.net/kMARn/1/
Move the slider to the right and the panel will open.
I have tried using the .not() selector for the panel to not react on the slider:
$(document).not("#slider").on("swiperight", function(event, ui) {
$("#myPanel").panel("open");
});
But it won't work, the panel opens when i move the slider to the right. Tried a bunch of variants too, but I'm lost...
Any ideas?
Thanks!
A bit late to the party, but you can disable swipe-to-close by setting the data-swipe-close attribute to "false" on the panel div.
http://jquerymobile.com/demos/1.3.0-beta.1/docs/panels/options.html
In my case I used this simple code, without data-swipe-close = "false" in panel.
Keeping panel close with swipe right, outside of the slider.
$('#panel').find('#slider')
.on('slidestop',function(e,ui) {
var value = e.target.value;
//...operations with slider value...
})
.parent().on('swiperight',function(e,ui) {
e.stopPropagation(); //block panel close
})
From the 1.3.0b1 Docs for Swipe:
"Triggers when a horizontal drag of 30px or more (and less than 75px
vertically) occurs within 1 second duration"
This applies to and can be configured for swiperight too. You can make the slider small in length and this would ensure that both the slider event stop and the swipe are not triggered at the same time, yet that may not be practical for all scenarios.
What might be better is to bind the swipe right to a DIV or section of the page. By this, I mean if you have a 75 px div box on the left hand side of the display, and when a swipe event occurred within that div, it could trigger the menu.
I feel the logic here might be better controlled by a button, much like used in the Facebook App to display there slide out menu. In the Dolphin browser on Android, this type of event also triggers a bookmark menu, so if a page has a swiperight event and trigger it, I sometimes get both the event and the bookmark menu from the App. Annoying!
I did fork your jsfiddle and will play with it more (http://jsfiddle.net/Twisty/Hg2pw/). FYI, they have JQM 1.3.0b1 in their available frameworks so you don't have to link it in your HTML. If I find some more info, I will comment here.
The following solution is more a workaround. It should be relatively reliable though.
$(document).ready( function () {
var menu_available = true;
$(document).on("swiperight", function(event, ui) {
if (menu_available) $("#myPanel").panel("open");
});
$("#slider").on("slidestop", function( event, ui ) {
menu_available = false;
window.setTimeout(function() {menu_available= true;},250);
});
});
The variable menu_available is false for a 250 milliseconds right after the slide stops. The window.setTimeout block will reset the variable so that the menu is available again.
This is a stupid workaround, but jQuerys function event.stopEventPropagation(), which IMHO would be the correct way to go, didn't work.

How to hide jQuery UI Slider on blur?

I have an image that opens the jQuery UI Slider div on click and allows users to set a value by dragging the handle. What I'm trying to do now is hide that handle when the user clicks anywhere else on the page, but the regular .blur event doesn't seem to work.
$("#openPriceToSliderGif").click(function(){
$("#slider-vertical").show();
$("#slider-vertical").focus();
});
$("#slider-vertical").blur(function () {
$("#slider-vertical").hide();
});
Probably you will have a better luck on defining global onclick handler and there you need to check if source of event is not your slider. If not - do your magic.
Basically - if you spinner doesn't include element such as text field or link it will not support focus/blur
Ok, this is what I have put together to make this work.
Thanx DroidIn.net for your help.
$(document).bind("click", function(e){
if(e.target.id != "openPriceToSliderGif")
$("#slider-vertical").hide();
return false;
});
$("#openPriceToSliderGif").click(function(){
$("#slider-vertical").toggle();
});

Open layer 3 + how make it behave like google map when mouse scroll

Google maps API show a message over the map when user scroll with mouse over the map.
The message advice the user must press control key while scroll with mouse over map.
This is a very nice solution to preserve normal page scroll with the mouse.
How can We do this in open layer 3+ API. Is thus possible? Please a need this behavior.
Thank you in advance.
Here the answers to your questions:
How to detect that the user is doing scroll on the map with the mouse and show an alert that you must press control key?
map.on('wheel', function(){
//write whatyou like and add it in popup window
});
How can you make it so the zoom on the map can only be done by pressing control in addition to scrolling with the mouse?
OpenLayers doesn't have this functionality but you can do it by changing ol.js as you want.
A helpful similar function can be found here
Also, you can do it with only (shift key) or (alt key)
map.on('wheel', function(evt) {
map.on('wheel', function(evt) {
wheelZoom(evt);
});
function wheelZoom(evt) {
if (ol.events.condition.shiftKeyOnly(evt) !== true) {
evt.browserEvent.preventDefault();
}
};

Resources