All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.swm.gwt.client.responsive.MatchMediaFacade Maven / Gradle / Ivy

The newest version!
package de.swm.gwt.client.responsive;


import com.google.gwt.core.shared.GWT;

/**
 * Wrapper for the javascript matchMedia function.
* Based on patch/contribution at GWT bug tracker * Use a polyfill in case the browser doesn't support this function (see links below). * * Typical application example: *
 * MatchMediaFacade facade = MatchMediaFacade.getInstance();
 *		
 * IMatchMedia minWidth = facade.match("(min-width: 720px)");
 * minWidth.addMatchMediaChangeHandler(new IMatchMediaChangeHandler() {
 *			
 * 		@Override
 * 		public void onMatchMediaChange(IMatchMedia matchMedia) {
 * 			if (matchMedia.hasMatch() {
 * 			 	
 * 			}
 * 		}
 * });
 * 
* * @see Js MatchMedia * @see Polyfill * @see Example usages * @see Browser support * @see Match Media alternative JS lib. * * @author Ed Bras */ public final class MatchMediaFacade { private MatchMediaFacade() { } public static MatchMediaFacade getInstance() { return InstanceHolder.INSTANCE; } public native boolean isSupported() /*-{ return $wnd.matchMedia != null || $wnd.msMatchMedia != null; }-*/; public IMatchMedia match(final String mediaQuery) { return (mediaQuery == null) ? null : matchIntern(mediaQuery); } private native JsMatchMedia matchIntern(String mediaQuery) /*-{ return $wnd.matchMedia(mediaQuery); }-*/; private interface InstanceHolder { MatchMediaFacade INSTANCE = GWT.create(MatchMediaFacade.class); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy