<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>swiper &#8211; 萧邦的博客</title>
	<atom:link href="https://www.zlhlab.top/tag/swiper/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.zlhlab.top</link>
	<description>If not me who, If not now when</description>
	<lastBuildDate>Thu, 22 Feb 2018 13:10:18 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.6</generator>
	<item>
		<title>驭胜S330新车上市H5</title>
		<link>https://www.zlhlab.top/%e9%a9%ad%e8%83%9cs330%e6%96%b0%e8%bd%a6%e4%b8%8a%e5%b8%82h5/</link>
		
		<dc:creator><![CDATA[萧邦]]></dc:creator>
		<pubDate>Wed, 11 Oct 2017 14:42:32 +0000</pubDate>
				<category><![CDATA[H5]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[iScroll]]></category>
		<category><![CDATA[swiper]]></category>
		<guid isPermaLink="false">https://www.zlhlab.top/?p=349</guid>

					<description><![CDATA[这个H5项目是给驭胜S330新车上市做的。项目开屏信封进入，点击进入，随手指滚动进行场景和内容展现。场景采用手绘动效的。还包含展示车型详情、活动规则、预约试驾以及中奖结果页面。]]></description>
										<content:encoded><![CDATA[<h4><strong>项目描述</strong></h4>
<hr>
<p>这个H5项目是给驭胜S330新车上市做的。项目开屏信封进入，点击进入，随手指滚动进行场景和内容展现。场景采用手绘动效的。还包含展示车型详情、活动规则、预约试驾以及中奖结果页面。</p>
<h4><strong>技术选型和方案</strong></h4>
<hr>
<p>项目有4处采用了flash动画（开屏页、滚动页3处）。由于IOS和安卓的特性，手机对flash的支持各异。初步进行flv-&gt;MP4视频，然后使用PS将视频转成单张图片（使用gif或者制作精灵图，机型不同手机内存和性能展现结果不一）。</p>
<p>技术方案和问题解决如下：</p>
<p>1、加载和缓存动画图片；<br />
2、采用canvas播放，播放缓存图片（750&#215;1206），实现帧动画；<br />
3、解决canvas播放动画手机端模糊问题，使用下面的解决方案：</p>
<pre class="line-numbers prism-highlight" data-start="1"><code class="language-javascript">var getPixelRatio = function(context) {
  var backingStore = context.backingStorePixelRatio ||
    context.webkitBackingStorePixelRatio ||
    context.mozBackingStorePixelRatio ||
    context.msBackingStorePixelRatio ||
    context.oBackingStorePixelRatio ||
    context.backingStorePixelRatio || 1;
   return (window.devicePixelRatio || 1) / backingStore;
};

//调用
var ratio = getPixelRatio(ctx);
</code></pre>
<p>4、使用iscroll-prob.js实现基于位置滚动加载；<br />
5、使用swiper实现详情页的动态展示。解决swiper安卓机型滑动问题，修改参数如下：</p>
<pre class="line-numbers prism-highlight" data-start="1"><code class="language-javascript">observer: true,//修改swiper自己或子元素时，自动初始化swiper  
observeParents: true,//修改swiper的父元素时，自动初始化swiper  
</code></pre>
<h4><strong>待优化</strong></h4>
<hr>
<p>项目已进行了优化，基本满足客户上线需求。</p>
<p>1.由于存在大量图片加载，会出现页面99%的时间较长。如果加载更平滑一些，loading页面看起来会自然一些。<br />
2.后续建议：针对简单的帧动画能用代码实现，尽量用代码实现，减少使用图片。</p>
<h4><strong>设计与发布地址</strong></h4>
<hr>
<p><img decoding="async" src="https://www.zlhlab.top/wp-content/uploads/2017/10/%E6%A1%88%E4%BE%8B%E5%9B%BE-%E9%A9%AD%E8%83%9C-1.jpg" alt=""></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>广汽丰田汉兰达&#8211;大汉是怎么炼成的</title>
		<link>https://www.zlhlab.top/swiper%e5%b5%8c%e5%a5%97%e5%ae%89%e5%8d%93%e6%9c%ba%e5%9e%8b%e5%8d%a1%e9%a1%bf%e9%97%ae%e9%a2%98%e6%80%bb%e7%bb%93/</link>
		
		<dc:creator><![CDATA[萧邦]]></dc:creator>
		<pubDate>Wed, 28 Jun 2017 06:35:20 +0000</pubDate>
				<category><![CDATA[H5]]></category>
		<category><![CDATA[swiper]]></category>
		<category><![CDATA[重力感应]]></category>
		<guid isPermaLink="false">https://www.zlhlab.top/?p=92</guid>

					<description><![CDATA[H5以“大汉是怎么炼成的”为主题，盘点汉兰达车型亮点。传播产品动力及综合性、省油、安全性等特点。通过简单的互动形式，深度传播产品卖点]]></description>
										<content:encoded><![CDATA[<p class="p1"><span class="s1" style="font-family: helvetica, arial, sans-serif;">H5以“大汉是怎么炼成的”为主题，盘点汉兰达车型亮点。传播产品动力及综合性、省油、安全性等特点。通过简单的互动形式，深度传播产品卖点。</span></p>
<p><span class="s1" style="font-family: helvetica, arial, sans-serif;">在广汽汉兰达项目中，使用swiper进行分页和关键点分页展示和swiper.animate.js进行动画切换。</span></p>
<h2 class="p1"><span class="s1" style="font-family: helvetica, arial, sans-serif;"><strong>项目技术元素</strong>：</span></h2>
<p class="p1"><span class="s1" style="font-family: helvetica, arial, sans-serif;">video标签、重力感应、摇一摇切屏、canvas绘制背景、swiper 3d切换，以及包含大量循环的CSS3动画(如车灯、轮胎、循环路背景)。</span></p>
<h2><span style="font-family: helvetica, arial, sans-serif;"><strong>开发难点：</strong></span></h2>
<ol>
<li><span style="font-family: helvetica, arial, sans-serif;">swiper多重嵌套；</span></li>
<li><span style="font-family: helvetica, arial, sans-serif;">视频和大量CSS3动画，出现安卓机型卡顿问题。</span></li>
</ol>
<p> </p>
<h2 class="p1"><span class="s1" style="color: #000000; font-family: helvetica, arial, sans-serif;"><strong>项目解决思路和方法如下</strong>：</span></h2>
<ol>
<li class="p1"><span class="s1" style="font-family: helvetica, arial, sans-serif;">之前阅读知道大量css3动画会导致界面渲染出现卡顿。路采用css3动画进行路的循环，由于山的背景图比较大，开始采用div进行背景循环，然后重力感应进行背景旋转，效果不太理想。于是山的背景图采用canvas方式渲染，然后旋转canvas来适应重力感应。</span></li>
<li class="p1"><span class="s1" style="font-family: helvetica, arial, sans-serif;">元素非循环动画采用ani动画，循环动画使用css3，在swiper切换的时候进行显示影藏。</span></li>
<li class="p1"><span class="s1" style="font-family: helvetica, arial, sans-serif;">进行一个个page检查，发现video标签，不在当前选择页面，还是会进行数据加载，导致界面卡顿。于是针对video标签，仅在当前选择状态，才设置其可见。</span></li>
<li class="p1"><span class="s1" style="font-family: helvetica, arial, sans-serif;">由于子项swiper主要进行卖点介绍，包含大量的图片。在项目构建时，将子项swiper直接嵌入，发现会导致长时间延时。于是将子项swiper嵌套在div当中，在切换到当前页时，动态加载子项swiper包含的内容，当切换出当前页，移除子项swiper包含的元素。</span></li>
<li class="p1"><span class="s1" style="font-family: helvetica, arial, sans-serif;">通过代码优化和细节调整，终于使得项目在安卓机型下流畅的运行。</span></li>
<li class="p1"><span class="s1" style="font-family: helvetica, arial, sans-serif;">搞定。终于可以好好休息下了~</span></li>
</ol>
<h2><span style="font-family: helvetica, arial, sans-serif;"><strong>项目UI设计与地址:</strong></span></h2>
<p><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-359" src="https://www.zlhlab.top/wp-content/uploads/2017/06/%E6%B1%89%E5%85%B0%E8%BE%BE-1.jpg" alt="" width="1228" height="3331"></p>
<p> </p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
