<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by 蔓蒂 on Medium]]></title>
        <description><![CDATA[Stories by 蔓蒂 on Medium]]></description>
        <link>https://medium.com/@amin40450102?source=rss-10095570dba5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5afBps17tRNGOt_zaGuouA.png</url>
            <title>Stories by 蔓蒂 on Medium</title>
            <link>https://medium.com/@amin40450102?source=rss-10095570dba5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 05:21:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amin40450102/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[PM日常-Day1]]></title>
            <link>https://medium.com/@amin40450102/pm%E6%97%A5%E5%B8%B8-day1-a1c1789696e?source=rss-10095570dba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1c1789696e</guid>
            <dc:creator><![CDATA[蔓蒂]]></dc:creator>
            <pubDate>Wed, 19 Oct 2022 05:01:41 GMT</pubDate>
            <atom:updated>2022-10-19T05:01:41.459Z</atom:updated>
            <content:encoded><![CDATA[<p>一大早就起床了，畢竟路途遙遠，新的工作車程50分鐘，沒想到找停車位花了不久時間呀~~</p><p>早上是新生訓練，HR介紹公司產品，但我對公司產品沒有涉略，連他們代言人是誰我都不知道😂😂，還講解了福利等，接著有人來上資安的課，覺得那位講者還蠻好笑的😂</p><p>HR帶我們去各樓層參觀，結束後竟然給了我們一大袋的新生大禮包🎁，裡面東西很多有衣服、外套、快篩、文具、水壺，回家時穿了公司的外套覺得很不錯，不然我應該會冷死🥶🥶</p><p>下午就各自被帶回去，有了自己的座位，開始設定一些帳號密碼，及一些工作會用到的軟體，意外的是想要多一個螢幕但是三個月後才能申請😯😯</p><p>第一天就這樣過去了～～辦公室的姐姐說時間到了就準時下班，不要不好意思，RD會待比較晚是因為他們比較晚來，從RD轉PM的工作模式我還不太習慣😂😂，持續適應中😀</p><p>❗️回家竟然忘了阿姊一直叫我去領蝦皮！！！太扯，根本失憶了！</p><p>❗️廁所竟然有提供衛生棉</p><p>❗️竟然可以準時下班</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1c1789696e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 30— Whack A Mole]]></title>
            <link>https://medium.com/@amin40450102/day-30-whack-a-mole-aa10a9e44ec2?source=rss-10095570dba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa10a9e44ec2</guid>
            <dc:creator><![CDATA[蔓蒂]]></dc:creator>
            <pubDate>Wed, 03 Jun 2020 06:06:22 GMT</pubDate>
            <atom:updated>2020-06-03T06:06:22.712Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NHBnOs9q6ctS_o-cUUvy1w.jpeg" /></figure><h4>第三十天任務:</h4><p>製作一個打地鼠的遊戲</p><ol><li>讓地鼠可以隨機從地洞出現</li><li>地鼠出現後停留在畫面的時間長度不一</li><li>點到地鼠後記分板可以記分</li></ol><h4>作法:</h4><ol><li>取得隨機的位置，透過Math.random()取得亂數( 0&lt;=x&lt;1)，再用Math.floor()將所有的小數無條件捨去到比自身小的最大整數，但我們的地洞有6個，所以要乘上6，結果會出現0-5的隨機數字</li></ol><p>因為是隨機的，所以有可能重複出現相同的地洞，所以用一個變數紀錄上個地洞，讓上個地洞跟這次地洞不要是同一個，如果剛好是同一個就請它重新跑，直到不是為止</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*m-FnBVTqVBOMbT3MXixUzQ.jpeg" /></figure><p>2. 接著處理地鼠隨機出現的時間，設計一個隨機時間的function，在第28天有說到取得區間範圍的方法，參數設定最大值跟最小值，實際的時間後面再做處理</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*hWmLpzqN5uh80BgJ-dllyw.jpeg" /></figure><p>3. 有了隨機的地數跟時間後，要把地鼠呼叫出來了，設計一個地鼠出現的function，在css中有一個up的class，是用來處理讓地鼠出現的，透過classList.add來讓地鼠出現，但是出現之後要躲回去，好讓使用者點不到，先在外面建立一個用來判斷時間是否結束的變數，false代表還沒結束，true則代表已經結束了</p><p>使用setTimeout()來設定時間，讓地鼠第一次出現時經過了time後移除class，並判斷如果時間未結束則在執行srart()，直到時間結束，這邊時間指的是玩遊戲的時間，如果時間設定10秒，則看使用者能在這10秒打幾個地鼠，打到一隻就得一分~~</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*XRiuVLHR0tkuSUKLbJWmLQ.jpeg" /></figure><p>透過手動呼叫start()可以看到每個地洞跟時間是什麼</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*klr53-IUJ43gv1YxqUg7gQ.jpeg" /></figure><p>4. 把打到地鼠分數印在畫面上，取到所有的地鼠，並設計點擊事件</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*k8dJ1-1UBHAoNYImVeFIKA.jpeg" /></figure><p>透過console.log可以看到點到地鼠會出現什麼資訊，其中有一個isTrusted屬性，若事件物件是由使用者操作而產生，則isTrusted 值為 true，來避免作弊的發生</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*Hz0vLiE--Mao0PtaGpzPsw.jpeg" /></figure><p>參閱：MDN：<a href="https://developer.mozilla.org/zh-TW/docs/Web/API/Event/isTrusted">Event.isTrusted</a></p><p>5. 先確定是否為使用者點擊，如果是的話，打到幾隻地鼠則score則變幾分，並把它印到畫面上</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*GZf0QT0-BAmBavNBZLilnQ.jpeg" /></figure><p>6. 最後設計一個遊戲的時間，總不能一直讓使用者無限一直玩，這樣計分也沒意義了，取得button按鈕，當使用者點擊按鈕時，記分板先歸0，把時間設成false是為了讓點擊button開始遊戲前都重新設定，要讓遊戲結束，我們設定10秒，過了10秒遊戲就結束了，地鼠也不會出現，使用者也無法點擊地鼠，這時候記分板就是使用者的分數</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*DpSZh6SrqJT41RYoHk3vAA.jpeg" /></figure><p>以上就是js30最後一天實作心得~~</p><p>附上codepen： <a href="https://codepen.io/aminwang/pen/XWmQWLj?editors=0011">30 — Whack A Mole</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa10a9e44ec2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 29— Countdown Timer]]></title>
            <link>https://medium.com/@amin40450102/day-29-countdown-timer-eca4d1805181?source=rss-10095570dba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/eca4d1805181</guid>
            <dc:creator><![CDATA[蔓蒂]]></dc:creator>
            <pubDate>Wed, 03 Jun 2020 06:06:09 GMT</pubDate>
            <atom:updated>2020-06-03T06:06:09.804Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*02j9AvNewNix-OmqD7-J4w.jpeg" /></figure><h4>第二十九天任務:</h4><p>點選上方按鈕，則會在畫面開始倒數，並出現最後時間</p><ol><li>運用setInterval製作倒數計時器</li><li>把倒數的秒數及最後的秒數印在畫面上</li></ol><h4>作法:</h4><p>1. 在html裡，我們設置了自訂義資料屬性，存取的數值就是代表倒數的秒數</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*zBzh-0VxseC6mRw-HN0wPQ.jpeg" /></figure><p>再利用querySelectorAll取上方每個按鈕，把存取的數值取出來</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*WySz6DPOWPjVQItK13ASwA.jpeg" /></figure><p>結果會是字串，但因為之後要做計算，所以利用parseInt()把字串轉成整數</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*dLhTNjG7WEIW7-ATf45GzQ.jpeg" /></figure><p>參閱：<a href="https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/parseInt">MDN：parseInt()</a></p><p>2. 接著處理右上方可輸入數字的input，在<a href="https://medium.com/@amin40450102/day-15-localstorage-d7dd0080538f">第15天</a>有說到submit事件，在按下enter鍵後，畫面會有跳轉的現象，所以先取消掉預設，之後取出使用者輸入的數字，但是預設顯示是輸入分鐘，所以*60把它變成秒，以便後續計算。</p><p>跟上個步驟一樣，結果會是字串，所以也是要把它轉成數字，最後使用第15天提到的<a href="https://medium.com/@amin40450102/day-15-localstorage-d7dd0080538f">this.reset()</a>來清空欄位</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*j_DV1hLzClyk6781M1MPtQ.jpeg" /></figure><p>3. 這時候就可以來開計時器了，先宣告一個名稱，之後清除可以用，再設計一個計時器，並把console.log換成timer，這樣就可以把參數傳進去</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*Zoo84ljNR7CDoA400tEOAg.jpeg" /></figure><p>4. 之後要做兩件事情，1.算最終加秒數的時間並打印在畫面上 2.倒數的計時器，也要打印在畫面上，在做之前要先清除計時器clearInterval(time)，因為程序每一次初始化的時候都調用一次計時器，之前的定時器實例沒有被銷毀，新的計時器又開始執行，就會出現1s變0.5s，0.5s變0.25秒的情況，從觀感上來看就是計時器「越走越快」了，清除完計時器後，要再把time設在裡面，這樣才有辦法每次都清掉</p><p>參閱：<a href="https://kknews.cc/code/bm4b3mm.html">JavaScript定時器越走越快的問題</a></p><p>取得目前時間戳，有幾種方法：</p><ul><li>Date.now()</li><li>new Date().getTime()</li><li>new Date().valueOf()</li></ul><p>取出來後在加上秒數，就是最終的時間，但是now的單位是毫秒，所以sec要*1000</p><p>最終時間=當前時間+按下秒數</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*wRj3euy_ax2M-PnByUYCUA.jpeg" /></figure><p>接著要把最終時間印在倒畫面上，像這樣，有小時跟分鐘</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*VZJG9Md9La2mQXhIfys7ZQ.jpeg" /></figure><p>取出最終時間的小時跟分鐘後，在把時間印在畫面上，有幾種方式</p><ul><li>innerHTML</li><li>innerText</li><li>textContent</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*d1SV_XDq-YEyV0QZuqLXjw.jpeg" /></figure><p>製作倒數計時器，使用setInterval()，讓最終時間減掉當前時間就是所經過的時間，出來會是毫秒，所以除以1000變成秒，之後要換算成分鐘跟秒鐘，並打印在畫面上，但出來結果變得很奇怪，有毫秒的問題(因為Date.now()後面會有一些毫秒)跟負數問題</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8EULqjFVr1-o-IWkY4vIHQ.jpeg" /><figcaption><strong>毫秒問題</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*DwLJzj3V-EI28ikaQigJwg.jpeg" /><figcaption><strong>負數問題</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*YMYXlinH0TXu853V-5xR6A.jpeg" /><figcaption><strong>補0問題，希望顯示出來是0:06</strong></figcaption></figure><p>解決負數的問題：讓它判斷，如果時間等於等於0，才執行，否則就清除計時器</p><p>解決毫秒問題：透過Math.floor() 將所有的小數無條件捨去到比自身小的最大整數</p><p>解決補0問題：透過三元運算子(條件?成立:不成立)來判斷要不要補0，如果秒數小於10就補0，否則就不動它</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*07nAsotnIGDdUaMaUIrH8Q.jpeg" /></figure><p>這邊的秒數不設成1000而是設成16，16(1000/60)毫秒更新就是所謂的60fps，這樣子它每秒會更新60次，讓計時器變得更準確</p><p>參閱：<a href="https://www.reneelab.net/frames-per-second.html">https://www.reneelab.net/frames-per-second.html</a></p><p>以上就是倒數第2天心得~~</p><p>附上<a href="https://codepen.io/aminwang/pen/LYpqmjM?editors=0010">codepen：29 — Countdown Timer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eca4d1805181" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day28 — Video Speed Controller]]></title>
            <link>https://medium.com/@amin40450102/day28-video-speed-controller-d9fd0938823a?source=rss-10095570dba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9fd0938823a</guid>
            <dc:creator><![CDATA[蔓蒂]]></dc:creator>
            <pubDate>Wed, 03 Jun 2020 06:05:57 GMT</pubDate>
            <atom:updated>2020-06-03T06:05:57.902Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day28 — Video Speed Controller</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FbkI19_wxaeAUEg9blI59A.jpeg" /></figure><h4>第二十八天任務:</h4><p>跟第11天任務很像，這次任務是用滑鼠可以控制影片的播放速度</p><ol><li>計算出移動的滑鼠座標占控制器整個的高度多少</li><li>把區間變成0.4-4之前</li><li>透過video.playbackRate指定播放的速度</li></ol><h4>作法:</h4><ol><li>取出滑鼠所在的座標，在換算成比例</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*6CATZH-5PAWdu0IJWF9HkQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*le9U_TBXhSYvBMJcOlgv1Q.jpeg" /></figure><p>結果會是這樣，區間為0–1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*oHCP34g-bx9yKDxpFtx-uQ.jpeg" /></figure><p>處理高度，讓裡面的(漸層那塊)高度跟著我們滑鼠去變動</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*gAdwO1Vx0uazsJ816s1ArA.jpeg" /></figure><blockquote><em>Math.round()</em> <em>函數回傳四捨五入後的近似值</em></blockquote><p>參閱：MDN-<a href="https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Math/round">Math.round()</a></p><p>2. 讓區間變成0.4-4，才比較有速度的感覺，不然0-1要做速度的變化感覺怪怪的這邊先設定最大值跟最小值，之後再運用範圍調整的公式：</p><p>(0-1)*(大-小)+小</p><p>把速度是多少印在畫面上，先把percent * 100然後四捨五入，在除以100，這樣畫面就可以顯示成0.xx pxx了</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/108/1*x13yZEfu4TbHNUt8QZUcJg.jpeg" /><figcaption><strong>percent*100</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/116/1*jjcvN81YNm_3W5sx0-TEcg.jpeg" /><figcaption><strong>Math.round(percent*100)</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/116/1*KuuL-TH0L4n9bIHpDqrtlA.jpeg" /><figcaption><strong>Math.round(percent*100)/100</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*XoG9fcCkzNLA5qZi9RShgA.jpeg" /></figure><p>video有個playbackRate屬性，它可以設置或返回音頻/視頻的當前播放速度，讓我們在控制器控制速度時，video也跟著變</p><blockquote><em>playbackRate可以指定播放時的速率</em></blockquote><p>參閱：MDN-<a href="https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLMediaElement/playbackRate">HTMLMediaElement.playbackRate</a></p><p>以上就是第28天的實做心得~~</p><p>附上codepen： <a href="https://codepen.io/aminwang/pen/yLYZBMG?editors=0001">28-Video Speed Controller</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9fd0938823a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day27 — Click and Drag]]></title>
            <link>https://medium.com/@amin40450102/day27-click-and-drag-4113ee806b8d?source=rss-10095570dba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4113ee806b8d</guid>
            <dc:creator><![CDATA[蔓蒂]]></dc:creator>
            <pubDate>Mon, 01 Jun 2020 14:45:55 GMT</pubDate>
            <atom:updated>2020-06-01T14:45:55.732Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day27 — Click and Drag</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bq7k029L9IWsWckVLRxTBA.jpeg" /></figure><h4>第二十七天任務:</h4><p>當滑鼠按下後拖拉元素，總長有25個item</p><ol><li>計算移動的距離</li><li>讓scroll距離加上移動的距離</li></ol><h4>作法：</h4><ol><li>要做這個動畫，首先要先點下去→之後再拖拉→拖拉完放開→動畫結束</li></ol><p>在第8天有說到mouse event</p><p>點下去：mousedown()</p><p>拖拉：mousemove()</p><p>放開：mouseup()</p><p>2. 點下去增加效果(放大及透明度)、取得滑鼠點下去時的座標，取出來的座標放在變數裡</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*V-q-65H3mXH2eBS6WVflcg.jpeg" /></figure><p>3. 計算位移的距離</p><p>末位置=初位置+位移</p><p>位移=末位置-初位置</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*T6a-vt7eAjtThvC_3V1Bjg.jpeg" /></figure><p>判斷mousemove()的前提有沒有點下去，如果沒有判斷則會一直觸發</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*MUxNLjY5_xmm_VtEyuszXQ.jpeg" /></figure><p>這邊可以看到往右拖拉跟往左拖拉的距離，並且從中發現</p><p>往右拖拉時，下方的scrollLeft是減少的</p><p>往左拖拉時，下方的scrollLeft是增加的</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SVJCyYnYdcMEQFeM958SMQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Tih1hfHqASN4-xTgK-GxQ.jpeg" /></figure><p>4. 透過console.dir()查看items的屬性及方法，裡面有個屬性scrollLeft可以算X捲軸的位置</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*UPrXyvLnV7A2mLxEjYT5-w.jpeg" /></figure><blockquote><em>console.dir() </em><strong><em>可以顯示一個對象的所有屬性和方法</em></strong></blockquote><p>參閱<a href="https://developer.mozilla.org/zh-CN/docs/Web/API/Console/dir">MDN-console.dir()</a></p><p>用scrollLeft去加上move就可以了，但是前面提到往右拖拉下方的scrollLeft是減少的，所以改用減號就能解決這個問題了，乘3是為了讓移動的距離變大，也可以不加，但就是每次拖拉都只有一點點</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*yxanw6vayujTd15efYY-Ig.jpeg" /></figure><p>5. 最後加上滑鼠放開時的清除特效，就大功告成了~~</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*wXDOSpurjFBJ_RIzJghDqw.jpeg" /></figure><p>以上就是今天的實作心得</p><p>附上<a href="https://codepen.io/aminwang/pen/oNjJENj?editors=0111">codepen:27-Click and Drag</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4113ee806b8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day26 — Stripe-Follow-Along-Nav]]></title>
            <link>https://medium.com/@amin40450102/day26-stripe-follow-along-nav-8901aa24ebf6?source=rss-10095570dba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8901aa24ebf6</guid>
            <dc:creator><![CDATA[蔓蒂]]></dc:creator>
            <pubDate>Mon, 01 Jun 2020 14:45:43 GMT</pubDate>
            <atom:updated>2020-06-01T14:45:43.583Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day26 — Stripe-Follow-Along-Nav</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*nYjjjlet4hXSLsfgQabPOA.jpeg" /></figure><h4>第二十六天任務:</h4><p>當滑鼠移到導覽列時，會出現內容，加上第22天學到的效果跟隨功能</p><ol><li>透過滑鼠移到導覽列的事件，讓左上角假的白區塊移動到導覽列下方真的區塊</li><li>讓假的白區塊寬高及座標等於真的區塊寬高+座標</li></ol><h4>作法；</h4><ol><li>先來看真的區塊的寬高，使用第22天學到的getBoundingClientRect()來取得寬高及位置</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*QCgOr-6M6zl0rCeW5MhPow.jpeg" /></figure><p>但結果卻都是0，那是因為在css中 我們把它的display設成none，要取得寬高及位置才能讓假的白區塊移動到正確的位置</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*zqhanX5xSOyQ4MPmjLr51g.jpeg" /></figure><p>所以先加上display:block，原本是display:none</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*qZ5AEZ4fm6hDq3TZIMPXDw.jpeg" /></figure><p>出來的結果就成功抓到寬高及位置了，但這時候畫面還是沒有出現，那是因為有用了opacity:0，動畫效果分兩次進行，先出現白框延遲幾秒後再出現文字</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*NnG7_S7I2iJwZI9VboFM4g.jpeg" /></figure><p>2. 把假的區塊位置及寬高設成剛剛取得到資訊，要記得加單位px</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*O5VIcS-_9_0VwoNNtXLElg.jpeg" /></figure><p>預期的結果是長這樣，滑鼠移入到導覽列時，假的區塊會跑到真的區塊中，這邊為了方便觀察，所以先把假的區塊 opacity設成1;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nv2FMBtXm-o9xU6nJSOuog.jpeg" /></figure><p>但是結果卻有點怪怪的，離導覽列有一段距離，跟我們預期的長得不太一樣，那是因為，top 的起點是 nav 上緣而不是瀏覽器上緣，這也是為什麼 白色區塊的位置會這麼下面了</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BGI5LxYgwWcdqLn0Vg0Zrg.jpeg" /></figure><p>加上座標</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*RPAzX31yQuHtxKnGH59l2Q.jpeg" /></figure><p>出來的結果就變成我們想要的樣子</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VsPUXVSD71pohYJNl8HRYw.jpeg" /></figure><p>剛剛有提到要先出現白框再延遲幾秒後再出現文字，使用setTimeout()來設定，為了方便觀察，我把延遲的時間變長了</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*JzYFsov9pysL-tzWqjQrgA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*nYjjjlet4hXSLsfgQabPOA.jpeg" /></figure><p>參閱：<a href="https://developer.mozilla.org/zh-CN/docs/Web/API/Window/setTimeout">MDN-setTimeout()</a></p><p>3. 最後設定滑鼠移出要做的事情，移入加add，移出的話就是remove</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*f9bKV5HdaZnwtv0cPNgfOw.jpeg" /></figure><p>以上就是今天的實作心得</p><p>附上<a href="https://codepen.io/aminwang/pen/GRpwZrx?editors=0111">codepen:26_Stripe-Follow-Along-Nav</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8901aa24ebf6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day25 — Event-Capture-Propagation-Bubbling-and-Once]]></title>
            <link>https://medium.com/@amin40450102/day25-event-capture-propagation-bubbling-and-once-1f790fc1385f?source=rss-10095570dba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f790fc1385f</guid>
            <dc:creator><![CDATA[蔓蒂]]></dc:creator>
            <pubDate>Mon, 01 Jun 2020 14:45:29 GMT</pubDate>
            <atom:updated>2020-06-01T14:45:29.276Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day25 — Event-Capture-Propagation-Bubbling-and-Once</h3><blockquote>今天任務要打開console才看的到~~</blockquote><h4>第二十五天任務:</h4><p>認識瀏覽器事件的運作原理capturing(捕獲)、bubbling(冒泡)</p><blockquote><em>capturing(捕獲)</em></blockquote><p>從外到內，如圖所示</p><blockquote><em>bubbling(冒泡)</em></blockquote><p>從內到外，如圖所示</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*FRmD4o5EENr3U8b0sNUKdg.jpeg" /></figure><p>addEventListener(1,2,3)</p><ol><li>事件類型</li><li>回乎函式</li><li>設定</li></ol><p>以往在寫事件時都不會設定第三個參數，第三個預設是false，有就是bubbling(冒泡)</p><ol><li>使用once:true來讓事件只觸發一次</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*SMjgtwp-6m47PrJ4W_7wtA.jpeg" /></figure><p>不管點幾次button都只會跑出一次</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/128/1*8IlBs8X5RsyPY2fNnU66PQ.jpeg" /></figure><p>如果改為false則會一直觸發</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*QcYT8Io0AWvdmNuPYBgaZw.jpeg" /></figure><p>可以觸發很多次</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/196/1*ouOQtDeQ6CihF461UnLdzA.jpeg" /></figure><p>2. 設定capturing(捕獲)模式，也就是capture為true</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*h2ozn-eZnzjapysECHvY4A.jpeg" /></figure><p>點擊中間橘框時，會由外到內</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/215/1*POQHeKbAPfEMs5moQWvtrA.jpeg" /></figure><p>如果設定capture為false，也就是bubbling(冒泡)，則會由內到外</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*iXQ560-drXWWFwNYL4mWrw.jpeg" /></figure><p>結果</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*Rh9wr7Fk_2KneCwtkddMpA.jpeg" /></figure><p>3. 增加stopPropagation()，代表把事件中斷，第一次觸發完就結束</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DiAciIxVfQblZ5imTHwSXQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iYQzwaYFyn8qt3iSmbt_Ow.jpeg" /></figure><p>參閱：<a href="https://developer.mozilla.org/zh-TW/docs/Web/API/Event/stopPropagation">MDN-stopPropagation()</a></p><p>以上就是今天的實作~~</p><p>附上<a href="https://codepen.io/aminwang/pen/pojQyEX?editors=0010">codepen：25_Event-Capture-Propagation-Bubbling-and-Once</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f790fc1385f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day24 — Sticky Nav]]></title>
            <link>https://medium.com/@amin40450102/day24-sticky-nav-258fe484328d?source=rss-10095570dba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/258fe484328d</guid>
            <dc:creator><![CDATA[蔓蒂]]></dc:creator>
            <pubDate>Sun, 31 May 2020 13:54:06 GMT</pubDate>
            <atom:updated>2020-05-31T13:54:06.169Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day24 — Sticky Nav</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OAcEKU9BtcgD_aL6j-edUg.jpeg" /></figure><h4>第二十四天任務:</h4><p>滾動捲軸，Navbar導覽列會釘在上方，並且logo會跑出來</p><ol><li>計算捲軸滾動的距離要等於或大於最上方區塊時讓Navbar釘住</li></ol><h4>作法：</h4><ol><li>在<a href="https://medium.com/@amin40450102/day13-slide-in-on-scroll-cadf8b7caa4d">第13天</a>有提到過scroll事件，當最上方header區塊高度小於等於scrollY時，讓Navbar的css定位變成fixed，並且讓logo寬度從0變成500，這樣logo就能從左方跑出來</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*xk6PsLfgoTmuNVXBBAvDbw.jpeg" /></figure><p>2. 這時候會發現，捲軸出來的結果會蓋到下方文字的地方</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zd0uHyXUpKx_VlQalxI_DA.jpeg" /></figure><p>我們可以直接增加body的paddingTop來把蓋住的文字往下移，這樣就不會擋住文字了，另外還可以用scale()讓內容的呈現效果放大，方便閱讀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*0e4kyyncfqzS0hkn-EYU7g.jpeg" /></figure><p>以上就是今天實作，這次範例在滿多網站上都看的到~~</p><p>附上<a href="https://codepen.io/aminwang/pen/ExVOjpW?editors=1000">codepen:24 — Sticky Nav</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=258fe484328d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 23— Speech Synthesis]]></title>
            <link>https://medium.com/@amin40450102/day-23-speech-synthesis-50be17667079?source=rss-10095570dba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/50be17667079</guid>
            <dc:creator><![CDATA[蔓蒂]]></dc:creator>
            <pubDate>Sun, 31 May 2020 13:53:46 GMT</pubDate>
            <atom:updated>2020-05-31T13:53:46.719Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*u_f3u966fucAvxuUwsiNDg.jpeg" /></figure><h4>第二十三天任務:</h4><p>製作文字轉聲音的語音合成 (Speech Synthesis)</p><ol><li>輸入文字案speck，就會轉成聲音</li><li>可以透過操作滑動桿 ( range slider )控制音調及速度</li></ol><h4>作法:</h4><ol><li>認識SpeechSynthesisUtterance及speechSynthesis</li></ol><ul><li>SpeechSynthesisUtterance</li></ul><p>它包含語音服務應閱讀的內容以及有關如何閱讀的信息（例如，語言、音調和音量）。</p><ul><li>speechSynthesis</li></ul><p>是語音業務的控制器接口，這可用於檢索有關設備上可用的合成語音，開始和暫停語音以及其他命令的信息。</p><p>參閱：<a href="https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance">MDN-SpeechSynthesisUtterance</a>、<a href="https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis">speechSynthesis</a></p><p>2. 首先創建一個語音需求的物件</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*r8SreR9IUWU1gEhZuE-Blw.jpeg" /></figure><p>透過console可以看到物件底下有許多資訊，有音調(pitch)、速度(rate)、文字內容(text)…等</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*5AgOiSrCmrJ_xaU_zFI-cA.jpeg" /></figure><p>3. 接著要讀什麼，我們使用SpeechSynthesisUtterance.text來達到，意思是獲取並設置在說出語音時講的文字，但實際上要讓它播出來要使用<a href="https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis">speechSynthesis</a>底下的一個叫做speak的屬性</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*oTO52if3913oyUvVESlfXA.jpeg" /></figure><p>4. speechSynthesis底下有一個voiceschanged的事件，當物件偵測到電腦裡的列表內容改變時觸發，所以如果有偵聽到voiceschanged的事件後就可以使用speechSynthesis.getVoices()拿到所有的瀏覽器支援的語音所組成的清單</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*1CtvylyW3e0c_hnM6dXkSg.jpeg" /></figure><p>瀏覽器支援的語音所組成的清單長這樣</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*eN8xw59x4mOyKmJzt5i-Pw.jpeg" /></figure><p>之後再把清單放到我們設定的下拉式選單中，用map組合成我們想要的格式並打印在畫面上</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*k4lwKxTo8J3kBly2FM162Q.jpeg" /></figure><p>用map()return回來的陣列發現會出現 “ , “</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jKKIOxM-wxkqsX0gV1feBw.jpeg" /></figure><p>於是使用join(&#39; &#39;)把逗號拿掉，結果如下</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFui6Zcyb3wQ82o82bEIOA.jpeg" /></figure><p>成功打印到畫面上~~</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gMqC-BkRilyDAnBZRX24Vg.jpeg" /></figure><p>5. 選到下拉式選單的任何語言時，都能發出指定的聲音，於是我們對select元素加上監聽事件，SpeechSynthesisUtterance的 voice屬性意思是獲取並設置將用於說出語音的聲音。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*H162xz2-950a3-IFCEkPSA.jpeg" /></figure><p>6. 但是單純撥出聲音這樣太無趣了，我們希望可以操作滑動桿 ( range slider )來控制音調及速度，這邊標籤name的設計命名的方式剛剛好是對應SpeechSynthesisUtterance的Property名稱，所以可以直接使用</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*mb-8ufNglfmmgp8Rxk_8vA.jpeg" /></figure><p>可以看到name跟value各是什麼</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*m1S_wk6QbrOGPwuZ_Ff10A.jpeg" /></figure><p>7. 最後偵聽stop()按鈕，要注意<a href="https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis">speechSynthesis</a>底下的canael()的意思是從語音裡中刪除所有語音。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*0cej-rlIufRGqyODXMj7HA.jpeg" /></figure><p>以上就是今天的實作~~</p><p>附上<a href="https://codepen.io/aminwang/pen/ZEbqwrQ?editors=0011">codepen：23 — Speech Synthesis</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50be17667079" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day22 — Follow Along Link Highlighter]]></title>
            <link>https://medium.com/@amin40450102/day22-follow-along-link-highlighter-b5fcc5f98184?source=rss-10095570dba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5fcc5f98184</guid>
            <dc:creator><![CDATA[蔓蒂]]></dc:creator>
            <pubDate>Sun, 31 May 2020 13:53:30 GMT</pubDate>
            <atom:updated>2020-05-31T13:53:30.024Z</atom:updated>
            <content:encoded><![CDATA[<h3>Day22 — Follow Along Link Highlighter</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*wevS5QtwBWIVetjHgQm4wg.jpeg" /></figure><h4>第二十二天任務:</h4><p>當滑鼠移動到關鍵字時，會出現highlight效果，</p><ol><li>讓highlight效果隨著滑鼠移動產生跟隨</li><li>當卷軸滾動時highlight效果也可以緊跟著</li></ol><h4>作法：</h4><ol><li>建立一個有class是highlight的span，並且使用display=&quot;none&quot;先把它隱藏。</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*ll1N3C5rcV0HJIxkXXCEqQ.jpeg" /></figure><p>2. 選取所有關鍵字，使用querySelectorAll()，並用forEach()把個別關鍵字都監聽滑鼠移入(mouseenter)的事件</p><ul><li>mouseenter：鼠標只會經過自身盒子觸發</li><li>mouseover：鼠標經過自身盒子會觸發，經過子盒子還會觸發</li></ul><p>3. 取得滑鼠摸到關鍵字的寬高，使用getBoundingClientRect()，此方法會返回元素的大小及其相對於窗口的位置</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*aW5Pajrbixg-CbtqhRrmrg.jpeg" /></figure><p>來看看console.log結果</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*kDJtYIQbY3FO0tb53EELYg.jpeg" /></figure><p>參閱：<a href="https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getBoundingClientRect">MDN-getBoundingClientRect()</a></p><p>4. 由於我們的highlight還未設定寬高，所以將指定元素的寬、高及位置指派給highlight，但是隨著轉軸滾動，位置就跑掉了，所以需要加上<a href="https://medium.com/@amin40450102/day13-slide-in-on-scroll-cadf8b7caa4d">第13天</a>學到到scrollX、scrollY，這樣子不管轉軸動到哪，highlight的位置就是正確的</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*f0qC4oqeRx51s4xVwvd0CQ.jpeg" /></figure><p>以上就是第22天實做紀錄</p><p>附上<a href="https://codepen.io/aminwang/pen/wvKYXxb?editors=1010">codepen:22 — Follow Along Link Highlighter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5fcc5f98184" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>