mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 20:22:20 +08:00
Updates github pages
This commit is contained in:
parent
fdbc5851c5
commit
aae3a8eafd
@ -378,7 +378,7 @@ p {
|
|||||||
padding: 4px 14px;
|
padding: 4px 14px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
background-color: rgba(105, 105, 105, 0.65);
|
background-color: rgba(105, 105, 105, 0.65);
|
||||||
font-family:'Open Sans', sans-serif;
|
font-family:'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
.footgraph {
|
.footgraph {
|
||||||
@ -409,6 +409,9 @@ p {
|
|||||||
height: 558px;
|
height: 558px;
|
||||||
background-color: #272822;
|
background-color: #272822;
|
||||||
}
|
}
|
||||||
|
.linkfoot {
|
||||||
|
color: #b3c2e3;
|
||||||
|
}
|
||||||
html.w-mod-js.w-mod-no-ios *[data-ix="slicefromleft"] {
|
html.w-mod-js.w-mod-no-ios *[data-ix="slicefromleft"] {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
-webkit-transform: translate(-100px, 0px);
|
-webkit-transform: translate(-100px, 0px);
|
||||||
|
BIN
images/email.png
BIN
images/email.png
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.7 KiB |
36
index.html
36
index.html
@ -1,6 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<!-- This site was created in Webflow. http://www.webflow.com-->
|
<!-- This site was created in Webflow. http://www.webflow.com-->
|
||||||
<!-- Last Published: Fri Jun 20 2014 17:48:26 GMT+0000 (UTC) -->
|
<!-- Last Published: Mon Jun 30 2014 02:10:44 GMT+0000 (UTC) -->
|
||||||
<html data-wf-site="539b89a7a7990e780bfd7c67">
|
<html data-wf-site="539b89a7a7990e780bfd7c67">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
@ -14,7 +14,7 @@
|
|||||||
<script>
|
<script>
|
||||||
WebFont.load({
|
WebFont.load({
|
||||||
google: {
|
google: {
|
||||||
families: ["Montserrat:400,700","Varela Round:400","Great Vibes:400","Varela:400","Open Sans:300,300italic,400,400italic,600,600italic,700,700italic,800,800italic","Vollkorn:400,400italic,700,700italic"]
|
families: ["Montserrat:400,700","Varela Round:400","Great Vibes:400","Varela:400","Vollkorn:400,400italic,700,700italic"]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@ -26,10 +26,10 @@
|
|||||||
<div class="section hero">
|
<div class="section hero">
|
||||||
<div class="w-container presenting" data-ix="fadein">
|
<div class="w-container presenting" data-ix="fadein">
|
||||||
<h1 class="hero-heading">Gin Gonic</h1>
|
<h1 class="hero-heading">Gin Gonic</h1>
|
||||||
<p class="hero-subhead">Fastest full-featured web framework for Golang. <strong>Crystal clear.</strong>
|
<p class="hero-subhead">The fastest full-featured web framework for Golang. <strong>Crystal clear.</strong>
|
||||||
</p>
|
</p>
|
||||||
<div class="button-group"><a class="button sign-up" href="https://github.com/gin-gonic/gin" data-ix="shaking">github pagE</a><a class="button" href="http://godoc.org/github.com/gin-gonic/gin">API REFERENCE</a>
|
<div class="button-group"><a class="button sign-up" href="https://github.com/gin-gonic/gin" data-ix="shaking">github pagE</a><a class="button" href="http://godoc.org/github.com/gin-gonic/gin">API REFERENCE</a>
|
||||||
<p class="goget"><span class="goget-text">go get github.com/gin-gonic/gin</span>
|
<p class="goget"><span class="goget-text">$ go get github.com/gin-gonic/gin</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -40,7 +40,8 @@
|
|||||||
<p class="section-subtitle">Gin is a web framework written in Golang. It features a martini-like API with much better performance, up to 40 times faster. If you need performance and good productivity, you will love Gin.</p>
|
<p class="section-subtitle">Gin is a web framework written in Golang. It features a martini-like API with much better performance, up to 40 times faster. If you need performance and good productivity, you will love Gin.</p>
|
||||||
<div class="graph-block">
|
<div class="graph-block">
|
||||||
<img class="graph-image" src="images/graph.png" alt="Martini vs Gin" width="827">
|
<img class="graph-image" src="images/graph.png" alt="Martini vs Gin" width="827">
|
||||||
<p class="footgraph"><a href="https://github.com/gin-gonic/go-http-routing-benchmark">Run the tests by yourself</a>
|
<p class="footgraph">2,3 GHz Intel Core i7 8 GB 1600 MHz DDR3, OS X 10.9.3</p>
|
||||||
|
<p class="footgraph"><a href="https://github.com/gin-gonic/go-http-routing-benchmark">Check out the benchmark suite</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -48,13 +49,13 @@
|
|||||||
<div class="section grey" id="features">
|
<div class="section grey" id="features">
|
||||||
<div class="w-container" data-ix="slicefromleft">
|
<div class="w-container" data-ix="slicefromleft">
|
||||||
<h2 class="section-title">Low Overhead Powerful API</h2>
|
<h2 class="section-title">Low Overhead Powerful API</h2>
|
||||||
<p class="section-subtitle">You can add global, per-group, and per-route middlewares, thousands of nested groups, nice JSON validation and rendering. And the performance will be still great! Gin uses <strong>httprouter</strong> internally, the fastest HTTP router for
|
<p class="section-subtitle">You can add global, per-group, and per-route middlewares, thousands of nested groups, nice JSON validation and rendering. And the performance will be still great. Gin uses <strong>httprouter</strong> internally, the fastest HTTP router for
|
||||||
Golang. Httprouter was created by <em>Julien Schmidt</em> and it’s based in a <a href="http://en.wikipedia.org/wiki/Radix_tree">Radix Tree</a> algorithm. This explains the good performance and scalability of Gin.</p>
|
Golang. Httprouter was created by Julien Schmidt and it’s based in a <a href="http://en.wikipedia.org/wiki/Radix_tree">Radix Tree</a> algorithm.</p>
|
||||||
<div class="w-row">
|
<div class="w-row">
|
||||||
<div class="w-col w-col-6">
|
<div class="w-col w-col-6">
|
||||||
<h3>Some cool middlewares</h3>
|
<h3>Some cool middlewares</h3>
|
||||||
<p>If you used Martini before, Gin will be familiar to you. If you don’t, you will need 10 minutes to learn everything.</p><a class="button sentrybutton" href="https://github.com/gin-gonic/gin-sentry">Check out the<br>Sentry midDlEware</a>
|
<p>If you used Martini before, Gin will be familiar to you. If you don’t, you will need 10 minutes to learn everything.</p><a class="button sentrybutton" href="https://github.com/gin-gonic/gin-sentry">Check out the<br>Sentry midDlEware</a>
|
||||||
<p>More coming soon!</p>
|
<p>More coming soon</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-col w-col-6">
|
<div class="w-col w-col-6">
|
||||||
<h3>Crystal Clear</h3>
|
<h3>Crystal Clear</h3>
|
||||||
@ -76,6 +77,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="w-slider-nav w-round"></div>
|
<div class="w-slider-nav w-round"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<p class="footgraph"><a href="https://github.com/gin-gonic/gin/blob/master/README.md">More examples in the README.md</a>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -110,7 +113,7 @@
|
|||||||
<div class="w-col w-col-4 w-col-small-4">
|
<div class="w-col w-col-4 w-col-small-4">
|
||||||
<div class="icons">V</div>
|
<div class="icons">V</div>
|
||||||
<h3>Routes grouping</h3>
|
<h3>Routes grouping</h3>
|
||||||
<p>Organize your routes better. Authorization required vs non required, different API versions... In addition, the groups can be nested unlimitedly without degrading performance!</p>
|
<p>Organize your routes better. Authorization required vs non required, different API versions... In addition, the groups can be nested unlimitedly without degrading performance.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-col w-col-4 w-col-small-4">
|
<div class="w-col w-col-4 w-col-small-4">
|
||||||
<div class="icons">VI</div>
|
<div class="icons">VI</div>
|
||||||
@ -162,19 +165,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<footer class="section footer">
|
<footer class="section footer">
|
||||||
<div class="w-container">
|
<div class="w-container">
|
||||||
<div class="w-row">
|
<div class="footer-text">Gin is developed and maintained by <em><a href="https://github.com/manucorporat" class="linkfoot">Manu Martinez-Almeida</a></em>.
|
||||||
<div class="w-col w-col-6">
|
<br>It uses the fantastic <em><a href="https://github.com/julienschmidt" class="linkfoot">Julien Schmidt</a> </em>’s httprouter.</div>
|
||||||
<div class="footer-text">Gin is developed and maintained by <em>Manu Martinez-Almeida</em>. It uses the fantastic <em>Julien Schmidt</em>’s httprouter.</div>
|
|
||||||
</div>
|
|
||||||
<div class="w-col w-col-6 right-footer-col">
|
|
||||||
<a class="w-inline-block social-icon" href="mailto:manu.valladolid@gmail.com">
|
|
||||||
<img src="images/email.png" width="30" alt="539f9748f281585418675de9_email.png">
|
|
||||||
</a>
|
|
||||||
<a class="w-inline-block social-icon" href="http://forzefield.com">
|
|
||||||
<img src="images/globe2.png" width="30" alt="539f982eb9e5e952181edbc2_globe2.png">
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
|
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
|
||||||
|
310
js/webflow.js
310
js/webflow.js
@ -406,103 +406,6 @@ window.tram=function(t){function i(t,i){var e=new Z.Bare;return e.init(t,i)}func
|
|||||||
* Licensed MIT (/blob/master/LICENSE.txt)
|
* Licensed MIT (/blob/master/LICENSE.txt)
|
||||||
*/
|
*/
|
||||||
(function($){if(!$.support.cors&&$.ajaxTransport&&window.XDomainRequest){var n=/^https?:\/\//i;var o=/^get|post$/i;var p=new RegExp('^'+location.protocol,'i');var q=/text\/html/i;var r=/\/json/i;var s=/\/xml/i;$.ajaxTransport('* text html xml json',function(i,j,k){if(i.crossDomain&&i.async&&o.test(i.type)&&n.test(i.url)&&p.test(i.url)){var l=null;var m=(j.dataType||'').toLowerCase();return{send:function(f,g){l=new XDomainRequest();if(/^\d+$/.test(j.timeout)){l.timeout=j.timeout}l.ontimeout=function(){g(500,'timeout')};l.onload=function(){var a='Content-Length: '+l.responseText.length+'\r\nContent-Type: '+l.contentType;var b={code:200,message:'success'};var c={text:l.responseText};try{if(m==='html'||q.test(l.contentType)){c.html=l.responseText}else if(m==='json'||(m!=='text'&&r.test(l.contentType))){try{c.json=$.parseJSON(l.responseText)}catch(e){b.code=500;b.message='parseerror'}}else if(m==='xml'||(m!=='text'&&s.test(l.contentType))){var d=new ActiveXObject('Microsoft.XMLDOM');d.async=false;try{d.loadXML(l.responseText)}catch(e){d=undefined}if(!d||!d.documentElement||d.getElementsByTagName('parsererror').length){b.code=500;b.message='parseerror';throw'Invalid XML: '+l.responseText;}c.xml=d}}catch(parseMessage){throw parseMessage;}finally{g(b.code,b.message,c,a)}};l.onprogress=function(){};l.onerror=function(){g(500,'error',{text:l.responseText})};var h='';if(j.data){h=($.type(j.data)==='string')?j.data:$.param(j.data)}l.open(i.type,i.url);l.send(h)},abort:function(){if(l){l.abort()}}}}})}})(jQuery);
|
(function($){if(!$.support.cors&&$.ajaxTransport&&window.XDomainRequest){var n=/^https?:\/\//i;var o=/^get|post$/i;var p=new RegExp('^'+location.protocol,'i');var q=/text\/html/i;var r=/\/json/i;var s=/\/xml/i;$.ajaxTransport('* text html xml json',function(i,j,k){if(i.crossDomain&&i.async&&o.test(i.type)&&n.test(i.url)&&p.test(i.url)){var l=null;var m=(j.dataType||'').toLowerCase();return{send:function(f,g){l=new XDomainRequest();if(/^\d+$/.test(j.timeout)){l.timeout=j.timeout}l.ontimeout=function(){g(500,'timeout')};l.onload=function(){var a='Content-Length: '+l.responseText.length+'\r\nContent-Type: '+l.contentType;var b={code:200,message:'success'};var c={text:l.responseText};try{if(m==='html'||q.test(l.contentType)){c.html=l.responseText}else if(m==='json'||(m!=='text'&&r.test(l.contentType))){try{c.json=$.parseJSON(l.responseText)}catch(e){b.code=500;b.message='parseerror'}}else if(m==='xml'||(m!=='text'&&s.test(l.contentType))){var d=new ActiveXObject('Microsoft.XMLDOM');d.async=false;try{d.loadXML(l.responseText)}catch(e){d=undefined}if(!d||!d.documentElement||d.getElementsByTagName('parsererror').length){b.code=500;b.message='parseerror';throw'Invalid XML: '+l.responseText;}c.xml=d}}catch(parseMessage){throw parseMessage;}finally{g(b.code,b.message,c,a)}};l.onprogress=function(){};l.onerror=function(){g(500,'error',{text:l.responseText})};var h='';if(j.data){h=($.type(j.data)==='string')?j.data:$.param(j.data)}l.open(i.type,i.url);l.send(h)},abort:function(){if(l){l.abort()}}}}})}})(jQuery);
|
||||||
/*!
|
|
||||||
* tap.js
|
|
||||||
* Copyright (c) 2013 Alex Gibson, http://alxgbsn.co.uk/
|
|
||||||
* Released under MIT license
|
|
||||||
*/
|
|
||||||
(function (window, document) {
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
function Tap(el) {
|
|
||||||
el = typeof el === 'object' ? el : document.getElementById(el);
|
|
||||||
this.element = el;
|
|
||||||
this.moved = false; //flags if the finger has moved
|
|
||||||
this.startX = 0; //starting x coordinate
|
|
||||||
this.startY = 0; //starting y coordinate
|
|
||||||
this.hasTouchEventOccured = false; //flag touch event
|
|
||||||
el.addEventListener('touchstart', this, false);
|
|
||||||
el.addEventListener('touchmove', this, false);
|
|
||||||
el.addEventListener('touchend', this, false);
|
|
||||||
el.addEventListener('touchcancel', this, false);
|
|
||||||
el.addEventListener('mousedown', this, false);
|
|
||||||
el.addEventListener('mouseup', this, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
Tap.prototype.start = function (e) {
|
|
||||||
if (e.type === 'touchstart') {
|
|
||||||
this.hasTouchEventOccured = true;
|
|
||||||
}
|
|
||||||
this.moved = false;
|
|
||||||
this.startX = e.type === 'touchstart' ? e.touches[0].clientX : e.clientX;
|
|
||||||
this.startY = e.type === 'touchstart' ? e.touches[0].clientY : e.clientY;
|
|
||||||
};
|
|
||||||
|
|
||||||
Tap.prototype.move = function (e) {
|
|
||||||
//if finger moves more than 10px flag to cancel
|
|
||||||
if (Math.abs(e.touches[0].clientX - this.startX) > 10 || Math.abs(e.touches[0].clientY - this.startY) > 10) {
|
|
||||||
this.moved = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Tap.prototype.end = function (e) {
|
|
||||||
var evt;
|
|
||||||
|
|
||||||
if (this.hasTouchEventOccured && e.type === 'mouseup') {
|
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
this.hasTouchEventOccured = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.moved) {
|
|
||||||
//create custom event
|
|
||||||
if (typeof document.CustomEvent !== "undefined") {
|
|
||||||
evt = new document.CustomEvent('tap', {
|
|
||||||
bubbles: true,
|
|
||||||
cancelable: true
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
evt = document.createEvent('Event');
|
|
||||||
evt.initEvent('tap', true, true);
|
|
||||||
}
|
|
||||||
e.target.dispatchEvent(evt);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Tap.prototype.cancel = function (e) {
|
|
||||||
this.hasTouchEventOccured = false;
|
|
||||||
this.moved = false;
|
|
||||||
this.startX = 0;
|
|
||||||
this.startY = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
Tap.prototype.destroy = function () {
|
|
||||||
var el = this.element;
|
|
||||||
el.removeEventListener('touchstart', this, false);
|
|
||||||
el.removeEventListener('touchmove', this, false);
|
|
||||||
el.removeEventListener('touchend', this, false);
|
|
||||||
el.removeEventListener('touchcancel', this, false);
|
|
||||||
el.removeEventListener('mousedown', this, false);
|
|
||||||
el.removeEventListener('mouseup', this, false);
|
|
||||||
this.element = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
Tap.prototype.handleEvent = function (e) {
|
|
||||||
switch (e.type) {
|
|
||||||
case 'touchstart': this.start(e); break;
|
|
||||||
case 'touchmove': this.move(e); break;
|
|
||||||
case 'touchend': this.end(e); break;
|
|
||||||
case 'touchcancel': this.cancel(e); break;
|
|
||||||
case 'mousedown': this.start(e); break;
|
|
||||||
case 'mouseup': this.end(e); break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
window.Tap = Tap;
|
|
||||||
|
|
||||||
}(window, document));
|
|
||||||
/* jshint ignore:end */
|
/* jshint ignore:end */
|
||||||
/**
|
/**
|
||||||
* ----------------------------------------------------------------------
|
* ----------------------------------------------------------------------
|
||||||
@ -955,120 +858,126 @@ Webflow.define('ix', function ($, _) {
|
|||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* ----------------------------------------------------------------------
|
* ----------------------------------------------------------------------
|
||||||
* Webflow: Touch events for jQuery based on tap.js
|
* Webflow: Touch events
|
||||||
*/
|
*/
|
||||||
Webflow.define('touch', function ($, _) {
|
Webflow.define('touch', function ($, _) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Tap = window.Tap;
|
var api = {};
|
||||||
var namespace = '.w-events-';
|
api.init = function (el) {
|
||||||
var dataKey = namespace + 'tap';
|
el = typeof el === 'string' ? $(el).get(0) : el;
|
||||||
var fallback = !document.addEventListener;
|
return el ? new Touch(el) : null;
|
||||||
|
|
||||||
// jQuery event "tap" - use click in old + non-touch browsers
|
|
||||||
$.event.special.tap = (fallback || !Webflow.env.touch) ? { bindType: 'click', delegateType: 'click' } : {
|
|
||||||
setup: function () {
|
|
||||||
$.data(this, dataKey, new Tap(this));
|
|
||||||
|
|
||||||
// Returning false instructs jQuery to use native `addEventListener` on the element.
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
teardown: function () {
|
|
||||||
var tap = $.data(this, dataKey);
|
|
||||||
if (tap && tap.destroy) {
|
|
||||||
tap.destroy();
|
|
||||||
$.removeData(this, dataKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returning false makes sure the native event handlers bound above are removed.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// No swipe events for old browsers
|
function Touch(el) {
|
||||||
if (fallback || !Object.create) return;
|
var active = false;
|
||||||
|
var dirty = false;
|
||||||
|
var useTouch = false;
|
||||||
|
var thresholdX = Math.min(Math.round(window.innerWidth * 0.04), 40);
|
||||||
|
var startX, startY, lastX;
|
||||||
|
|
||||||
// jQuery event "swipe"
|
el.addEventListener('touchstart', start, false);
|
||||||
dataKey = namespace + 'swipe';
|
el.addEventListener('touchmove', move, false);
|
||||||
|
el.addEventListener('touchend', end, false);
|
||||||
|
el.addEventListener('touchcancel', cancel, false);
|
||||||
|
el.addEventListener('mousedown', start, false);
|
||||||
|
el.addEventListener('mousemove', move, false);
|
||||||
|
el.addEventListener('mouseup', end, false);
|
||||||
|
el.addEventListener('mouseout', cancel, false);
|
||||||
|
|
||||||
$.event.special.swipe = {
|
function start(evt) {
|
||||||
setup: function () {
|
// We don’t handle multi-touch events yet.
|
||||||
$.data(this, dataKey, new Swipe(this));
|
var touches = evt.touches;
|
||||||
|
if (touches && touches.length > 1) {
|
||||||
// Returning false instructs jQuery to use native `addEventListener` on the element.
|
return;
|
||||||
return false;
|
|
||||||
},
|
|
||||||
teardown: function () {
|
|
||||||
var tap = $.data(this, dataKey);
|
|
||||||
if (tap && tap.destroy) {
|
|
||||||
tap.destroy();
|
|
||||||
$.removeData(this, dataKey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returning false makes sure the native event handlers bound above are removed.
|
active = true;
|
||||||
return false;
|
dirty = false;
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
if (touches) {
|
||||||
* Swipe - extends Tap, supports mouse swipes!
|
useTouch = true;
|
||||||
*/
|
startX = touches[0].clientX;
|
||||||
function Swipe(el) {
|
startY = touches[0].clientY;
|
||||||
Tap.call(this, el);
|
} else {
|
||||||
|
startX = evt.clientX;
|
||||||
|
startY = evt.clientY;
|
||||||
}
|
}
|
||||||
|
|
||||||
(function () {
|
lastX = startX;
|
||||||
var supr = Tap.prototype;
|
|
||||||
var proto = Swipe.prototype = Object.create(supr);
|
|
||||||
var threshold = Math.round(screen.width * 0.04) || 20;
|
|
||||||
if (threshold > 40) threshold = 40;
|
|
||||||
|
|
||||||
proto.start = function (e) {
|
|
||||||
supr.start.call(this, e);
|
|
||||||
this.element.addEventListener('mousemove', this, false);
|
|
||||||
document.addEventListener('mouseup', this, false);
|
|
||||||
this.velocityX = 0;
|
|
||||||
this.lastX = this.startX;
|
|
||||||
this.enabled = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
proto.move = _.throttle(function (e) {
|
|
||||||
if (!this.enabled) return;
|
|
||||||
var x = e.touches ? e.touches[0].clientX : e.clientX;
|
|
||||||
this.velocityX = x - this.lastX;
|
|
||||||
this.lastX = x;
|
|
||||||
if (Math.abs(this.velocityX) > threshold) {
|
|
||||||
this.end(e);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
proto.end = function (e) {
|
function move(evt) {
|
||||||
if (!this.enabled) return;
|
if (!active) return;
|
||||||
var velocityX = this.velocityX;
|
|
||||||
this.cancel();
|
if (useTouch && evt.type === 'mousemove') {
|
||||||
if (Math.abs(velocityX) > threshold) {
|
evt.preventDefault();
|
||||||
$(this.element).triggerHandler('swipe', { direction: velocityX > 0 ? 'right' : 'left' });
|
evt.stopPropagation();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
proto.destroy = function () {
|
var touches = evt.touches;
|
||||||
this.cancel();
|
var x = touches ? touches[0].clientX : evt.clientX;
|
||||||
supr.destroy.call(this);
|
var y = touches ? touches[0].clientY : evt.clientY;
|
||||||
};
|
|
||||||
|
|
||||||
proto.cancel = function () {
|
var velocityX = x - lastX;
|
||||||
this.enabled = false;
|
lastX = x;
|
||||||
this.element.removeEventListener('mousemove', this, false);
|
|
||||||
document.removeEventListener('mouseup', this, false);
|
|
||||||
supr.cancel.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
proto.handleEvent = function (e) {
|
if (Math.abs(velocityX) > thresholdX) {
|
||||||
if (e.type == 'mousemove') return this.move(e);
|
triggerEvent('swipe', evt, { direction: velocityX > 0 ? 'right' : 'left' });
|
||||||
supr.handleEvent.call(this, e);
|
cancel();
|
||||||
};
|
}
|
||||||
}());
|
|
||||||
|
|
||||||
|
// If pointer moves more than 10px flag to cancel tap
|
||||||
|
if (Math.abs(x - startX) > 10 || Math.abs(y - startY) > 10) {
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function end(evt) {
|
||||||
|
if (!active) return;
|
||||||
|
|
||||||
|
if (useTouch && evt.type === 'mouseup') {
|
||||||
|
evt.preventDefault();
|
||||||
|
evt.stopPropagation();
|
||||||
|
useTouch = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dirty) triggerEvent('tap', evt);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancel(evt) {
|
||||||
|
active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroy() {
|
||||||
|
el.removeEventListener('touchstart', start, false);
|
||||||
|
el.removeEventListener('touchmove', move, false);
|
||||||
|
el.removeEventListener('touchend', end, false);
|
||||||
|
el.removeEventListener('touchcancel', cancel, false);
|
||||||
|
el.removeEventListener('mousedown', start, false);
|
||||||
|
el.removeEventListener('mousemove', move, false);
|
||||||
|
el.removeEventListener('mouseup', end, false);
|
||||||
|
el.removeEventListener('mouseout', cancel, false);
|
||||||
|
el = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Public instance methods
|
||||||
|
this.destroy = destroy;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrap native event to supoprt preventdefault + stopPropagation
|
||||||
|
function triggerEvent(type, evt, data) {
|
||||||
|
var newEvent = $.Event(type, { originalEvent: evt });
|
||||||
|
$(evt.target).trigger(newEvent, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Listen for touch events on all nodes by default.
|
||||||
|
api.instance = api.init(document);
|
||||||
|
|
||||||
|
// Export module
|
||||||
|
return api;
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* ----------------------------------------------------------------------
|
* ----------------------------------------------------------------------
|
||||||
@ -2344,8 +2253,8 @@ Webflow.define('navbar', function ($, _) {
|
|||||||
data.el.on('setting' + namespace, handler(data));
|
data.el.on('setting' + namespace, handler(data));
|
||||||
} else {
|
} else {
|
||||||
addOverlay(data);
|
addOverlay(data);
|
||||||
data.button.on('click' + namespace, toggle(data));
|
data.button.on('tap' + namespace, toggle(data));
|
||||||
data.menu.on('click' + namespace, 'a', navigate(data));
|
data.menu.on('tap' + namespace, 'a', navigate(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger initial resize
|
// Trigger initial resize
|
||||||
@ -2441,13 +2350,14 @@ Webflow.define('navbar', function ($, _) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function outside(data) {
|
function outside(data) {
|
||||||
return function (evt) {
|
// Close menu when tapped outside
|
||||||
var target = evt.target;
|
return _.debounce(function (evt) {
|
||||||
// Close navbars when clicked outside
|
if (!data.open) return;
|
||||||
if (!data.el.has(target).length && !data.el.is(target)) {
|
var menu = $(evt.target).closest('.w-nav-menu');
|
||||||
|
if (!data.menu.is(menu)) {
|
||||||
close(data);
|
close(data);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function resize(i, el) {
|
function resize(i, el) {
|
||||||
@ -2495,7 +2405,7 @@ Webflow.define('navbar', function ($, _) {
|
|||||||
resize(0, data.el[0]);
|
resize(0, data.el[0]);
|
||||||
|
|
||||||
// Listen for tap outside events
|
// Listen for tap outside events
|
||||||
if (!designer) $doc.on('click' + namespace, data.outside);
|
if (!designer) $doc.on('tap' + namespace, data.outside);
|
||||||
|
|
||||||
// Update menu height for Over state
|
// Update menu height for Over state
|
||||||
if (animOver) setMenuHeight(data);
|
if (animOver) setMenuHeight(data);
|
||||||
@ -2547,7 +2457,7 @@ Webflow.define('navbar', function ($, _) {
|
|||||||
var animation = config.animation;
|
var animation = config.animation;
|
||||||
|
|
||||||
// Stop listening for tap outside events
|
// Stop listening for tap outside events
|
||||||
$doc.off('click' + namespace, data.outside);
|
$doc.off('tap' + namespace, data.outside);
|
||||||
|
|
||||||
if (immediate) {
|
if (immediate) {
|
||||||
tram(data.menu).stop();
|
tram(data.menu).stop();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user