diff --git a/.htaccess b/.htaccess new file mode 100644 index 00000000000..c99a53a313a --- /dev/null +++ b/.htaccess @@ -0,0 +1,8 @@ +# One day for image files + +Header set Cache-Control "max-age=86400, public" + +# One hour for css and js + +Header set Cache-Control "max-age=3600, public" + \ No newline at end of file diff --git a/README.md b/README.md index 4f6bc75c0c8..1cca77cbf3c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ +## Initial Google Pagespeed scores before optimization +Mobile: 27/100 +Desktop: 29/100 + +## Pagespeed scores after image optimization +Mobile: 72/100 +Desktop: 87/100 + ## Website Performance Optimization portfolio project Your challenge, if you wish to accept it (and we sure hope you will), is to optimize this online portfolio for speed! In particular, optimize the critical rendering path and make this page render as quickly as possible by applying the techniques you've picked up in the [Critical Rendering Path course](https://www.udacity.com/course/ud884). diff --git a/css/mobile.css b/css/mobile.css new file mode 100644 index 00000000000..bcc0db7c09a --- /dev/null +++ b/css/mobile.css @@ -0,0 +1,6 @@ + +/* Smartphones (portrait) */ +@media only screen and (max-width: 480px) { + body { font-size: 12px;} + header p { padding-left: 4.5em;} +} \ No newline at end of file diff --git a/css/style.css b/css/style.css index ea49bda6578..ae9e804dca2 100644 --- a/css/style.css +++ b/css/style.css @@ -1,49 +1,6 @@ -html { - font-size: 100%; - overflow-y: scroll; - -webkit-tap-highlight-color: rgba(0,0,0,0); - -ms-text-size-adjust: 100%; - -webkit-text-size-adjust: none; -} -body { margin: 0; font-size: 14px; line-height: 1.61; font-weight: 400; } -body, button, input, select, textarea { font-family: 'Open Sans', sans-serif; color: #333; } +/*@font-face { font-family: 'Open Sans', sans-serif; src: url('../fonts/Open_Sans/OpenSans-Regular.ttf') format('truetype'); }*/ +/*@font-face { font-family: 'Open Sans', sans-serif; font-weight: bold; src: url('../fonts/Open_Sans/OpenSans-Bold.ttf') format('truetype'); }*/ -a { color: #12C; } a:visited { color: #61C; } a:focus { outline: thin dotted; } a:hover, a:active { color: #c00; outline: 0; } - -b, strong { font-weight: bold; } -pre, code { font-family: monospace, monospace; font-size: 1em; } -ul, ol { margin: 1em 0; padding: 0 0 0 20px; } -img { border: 0; max-width: 100%; } - -body { background: #fff; } -header, footer, .container { max-width: 45em; margin: 0 auto; } - -header { padding: 0 0.5em; color: #C90B0B; } -header img { border-radius: 40px; float: left; } -header p { font-size:1.5em; font-weight: bold; padding-left: 4em;} -header p span { font-size: 0.8em; font-weight: normal;} - -.hero { padding: 2em; background-color: #f8f8f8; font-size:1.2em; - border-bottom: 1px solid #ccc; - border-top: 1px solid #ccc; -} - -.content { padding: 1em 1em; } -.content li { list-style-type: none; font-size: 1.1em;} -li img { float:left; padding-right: 1em; } -li p { font-size: 0.9em; font-style: italic; } - -footer { - padding: 0 0.5em; - border-top: 1px solid #ccc; -} -footer span { float: right; font-style: italic; } - -/* Smartphones (portrait) */ -@media only screen and (max-width: 480px) { - body { font-size: 12px;} - header p { padding-left: 4.5em;} -} diff --git a/css/style_orig.css b/css/style_orig.css new file mode 100644 index 00000000000..ea49bda6578 --- /dev/null +++ b/css/style_orig.css @@ -0,0 +1,49 @@ +html { + font-size: 100%; + overflow-y: scroll; + -webkit-tap-highlight-color: rgba(0,0,0,0); + -ms-text-size-adjust: 100%; + -webkit-text-size-adjust: none; +} +body { margin: 0; font-size: 14px; line-height: 1.61; font-weight: 400; } +body, button, input, select, textarea { font-family: 'Open Sans', sans-serif; color: #333; } + +a { color: #12C; } +a:visited { color: #61C; } +a:focus { outline: thin dotted; } +a:hover, a:active { color: #c00; outline: 0; } + +b, strong { font-weight: bold; } +pre, code { font-family: monospace, monospace; font-size: 1em; } +ul, ol { margin: 1em 0; padding: 0 0 0 20px; } +img { border: 0; max-width: 100%; } + +body { background: #fff; } +header, footer, .container { max-width: 45em; margin: 0 auto; } + +header { padding: 0 0.5em; color: #C90B0B; } +header img { border-radius: 40px; float: left; } +header p { font-size:1.5em; font-weight: bold; padding-left: 4em;} +header p span { font-size: 0.8em; font-weight: normal;} + +.hero { padding: 2em; background-color: #f8f8f8; font-size:1.2em; + border-bottom: 1px solid #ccc; + border-top: 1px solid #ccc; +} + +.content { padding: 1em 1em; } +.content li { list-style-type: none; font-size: 1.1em;} +li img { float:left; padding-right: 1em; } +li p { font-size: 0.9em; font-style: italic; } + +footer { + padding: 0 0.5em; + border-top: 1px solid #ccc; +} +footer span { float: right; font-style: italic; } + +/* Smartphones (portrait) */ +@media only screen and (max-width: 480px) { + body { font-size: 12px;} + header p { padding-left: 4.5em;} +} diff --git a/fonts/Open_Sans.zip b/fonts/Open_Sans.zip new file mode 100644 index 00000000000..b82217073f2 Binary files /dev/null and b/fonts/Open_Sans.zip differ diff --git a/fonts/Open_Sans/LICENSE.txt b/fonts/Open_Sans/LICENSE.txt new file mode 100644 index 00000000000..75b52484ea4 --- /dev/null +++ b/fonts/Open_Sans/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/fonts/Open_Sans/OpenSans-Bold.ttf b/fonts/Open_Sans/OpenSans-Bold.ttf new file mode 100644 index 00000000000..fd79d43bea0 Binary files /dev/null and b/fonts/Open_Sans/OpenSans-Bold.ttf differ diff --git a/fonts/Open_Sans/OpenSans-BoldItalic.ttf b/fonts/Open_Sans/OpenSans-BoldItalic.ttf new file mode 100644 index 00000000000..9bc800958a4 Binary files /dev/null and b/fonts/Open_Sans/OpenSans-BoldItalic.ttf differ diff --git a/fonts/Open_Sans/OpenSans-ExtraBold.ttf b/fonts/Open_Sans/OpenSans-ExtraBold.ttf new file mode 100644 index 00000000000..21f6f84a079 Binary files /dev/null and b/fonts/Open_Sans/OpenSans-ExtraBold.ttf differ diff --git a/fonts/Open_Sans/OpenSans-ExtraBoldItalic.ttf b/fonts/Open_Sans/OpenSans-ExtraBoldItalic.ttf new file mode 100644 index 00000000000..31cb688340e Binary files /dev/null and b/fonts/Open_Sans/OpenSans-ExtraBoldItalic.ttf differ diff --git a/fonts/Open_Sans/OpenSans-Italic.ttf b/fonts/Open_Sans/OpenSans-Italic.ttf new file mode 100644 index 00000000000..c90da48ff3b Binary files /dev/null and b/fonts/Open_Sans/OpenSans-Italic.ttf differ diff --git a/fonts/Open_Sans/OpenSans-Light.ttf b/fonts/Open_Sans/OpenSans-Light.ttf new file mode 100644 index 00000000000..0d381897da2 Binary files /dev/null and b/fonts/Open_Sans/OpenSans-Light.ttf differ diff --git a/fonts/Open_Sans/OpenSans-LightItalic.ttf b/fonts/Open_Sans/OpenSans-LightItalic.ttf new file mode 100644 index 00000000000..68299c4bc6b Binary files /dev/null and b/fonts/Open_Sans/OpenSans-LightItalic.ttf differ diff --git a/fonts/Open_Sans/OpenSans-Regular.ttf b/fonts/Open_Sans/OpenSans-Regular.ttf new file mode 100644 index 00000000000..db433349b70 Binary files /dev/null and b/fonts/Open_Sans/OpenSans-Regular.ttf differ diff --git a/fonts/Open_Sans/OpenSans-Semibold.ttf b/fonts/Open_Sans/OpenSans-Semibold.ttf new file mode 100644 index 00000000000..1a7679e3949 Binary files /dev/null and b/fonts/Open_Sans/OpenSans-Semibold.ttf differ diff --git a/fonts/Open_Sans/OpenSans-SemiboldItalic.ttf b/fonts/Open_Sans/OpenSans-SemiboldItalic.ttf new file mode 100644 index 00000000000..59b6d16b065 Binary files /dev/null and b/fonts/Open_Sans/OpenSans-SemiboldItalic.ttf differ diff --git a/img/2048_home.jpg b/img/2048_home.jpg new file mode 100644 index 00000000000..d79ae5808d6 Binary files /dev/null and b/img/2048_home.jpg differ diff --git a/img/mobilewebdev_home.jpg b/img/mobilewebdev_home.jpg new file mode 100644 index 00000000000..b0d20cf9d29 Binary files /dev/null and b/img/mobilewebdev_home.jpg differ diff --git a/img/profilepic.jpg b/img/profilepic.jpg index 855172dd836..20f13c1c282 100644 Binary files a/img/profilepic.jpg and b/img/profilepic.jpg differ diff --git a/img/wpo_home.jpg b/img/wpo_home.jpg new file mode 100644 index 00000000000..45fa0bb0ef6 Binary files /dev/null and b/img/wpo_home.jpg differ diff --git a/index.html b/index.html index 01ebf055996..f5efc8ad1c0 100644 --- a/index.html +++ b/index.html @@ -7,22 +7,54 @@ Cameron Pittman: Portfolio - - + - - + - // Optional TODO: replace with your Google Analytics profile ID. - ga('create', 'UA-XXXX-Y'); - ga('send', 'pageview'); - - - @@ -39,25 +71,25 @@
+ + + + + + + + + + + diff --git a/views/.htaccess b/views/.htaccess new file mode 100644 index 00000000000..c99a53a313a --- /dev/null +++ b/views/.htaccess @@ -0,0 +1,8 @@ +# One day for image files + +Header set Cache-Control "max-age=86400, public" + +# One hour for css and js + +Header set Cache-Control "max-age=3600, public" + \ No newline at end of file diff --git a/views/css/bootstrap-greg.min.css b/views/css/bootstrap-greg.min.css new file mode 100644 index 00000000000..55802dd8667 --- /dev/null +++ b/views/css/bootstrap-greg.min.css @@ -0,0 +1,14 @@ +/*! + * Bootstrap v3.3.7 (http://getbootstrap.com) + * Copyright 2011-2017 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + +/*! + * Generated using the Bootstrap Customizer (http://getbootstrap.com/customize/?id=3bcb7f82408a1e56370d45683aa59c20) + * Config saved to config.json and https://gist.github.com/3bcb7f82408a1e56370d45683aa59c20 + *//*! + * Bootstrap v3.3.7 (http://getbootstrap.com) + * Copyright 2011-2016 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + *//*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:0.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace, monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}html{font-size:10px;-webkit-tap-highlight-color:rgba(0,0,0,0)}input,button,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}a{color:#337ab7;text-decoration:none}a:hover,a:focus{color:#23527c;text-decoration:underline}a:focus{outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}figure{margin:0}img{vertical-align:middle}.img-responsive{display:block;max-width:100%;height:auto}.img-rounded{border-radius:6px}.img-thumbnail{padding:4px;line-height:1.42857143;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out;display:inline-block;max-width:100%;height:auto}.img-circle{border-radius:50%}hr{margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}[role="button"]{cursor:pointer}h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6{font-family:inherit;font-weight:500;line-height:1.1;color:inherit}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small,.h1 small,.h2 small,.h3 small,.h4 small,.h5 small,.h6 small,h1 .small,h2 .small,h3 .small,h4 .small,h5 .small,h6 .small,.h1 .small,.h2 .small,.h3 .small,.h4 .small,.h5 .small,.h6 .small{font-weight:normal;line-height:1;color:#777}h1,.h1,h2,.h2,h3,.h3{margin-top:20px;margin-bottom:10px}h1 small,.h1 small,h2 small,.h2 small,h3 small,.h3 small,h1 .small,.h1 .small,h2 .small,.h2 .small,h3 .small,.h3 .small{font-size:65%}h4,.h4,h5,.h5,h6,.h6{margin-top:10px;margin-bottom:10px}h4 small,.h4 small,h5 small,.h5 small,h6 small,.h6 small,h4 .small,.h4 .small,h5 .small,.h5 .small,h6 .small,.h6 .small{font-size:75%}h1,.h1{font-size:36px}h2,.h2{font-size:30px}h3,.h3{font-size:24px}h4,.h4{font-size:18px}h5,.h5{font-size:14px}h6,.h6{font-size:12px}p{margin:0 0 10px}.lead{margin-bottom:20px;font-size:16px;font-weight:300;line-height:1.4}@media (min-width:768px){.lead{font-size:21px}}small,.small{font-size:85%}mark,.mark{background-color:#fcf8e3;padding:.2em}.text-left{text-align:left}.text-right{text-align:right}.text-center{text-align:center}.text-justify{text-align:justify}.text-nowrap{white-space:nowrap}.text-lowercase{text-transform:lowercase}.text-uppercase{text-transform:uppercase}.text-capitalize{text-transform:capitalize}.text-muted{color:#777}.text-primary{color:#337ab7}a.text-primary:hover,a.text-primary:focus{color:#286090}.text-success{color:#3c763d}a.text-success:hover,a.text-success:focus{color:#2b542c}.text-info{color:#31708f}a.text-info:hover,a.text-info:focus{color:#245269}.text-warning{color:#8a6d3b}a.text-warning:hover,a.text-warning:focus{color:#66512c}.text-danger{color:#a94442}a.text-danger:hover,a.text-danger:focus{color:#843534}.bg-primary{color:#fff;background-color:#337ab7}a.bg-primary:hover,a.bg-primary:focus{background-color:#286090}.bg-success{background-color:#dff0d8}a.bg-success:hover,a.bg-success:focus{background-color:#c1e2b3}.bg-info{background-color:#d9edf7}a.bg-info:hover,a.bg-info:focus{background-color:#afd9ee}.bg-warning{background-color:#fcf8e3}a.bg-warning:hover,a.bg-warning:focus{background-color:#f7ecb5}.bg-danger{background-color:#f2dede}a.bg-danger:hover,a.bg-danger:focus{background-color:#e4b9b9}.page-header{padding-bottom:9px;margin:40px 0 20px;border-bottom:1px solid #eee}ul,ol{margin-top:0;margin-bottom:10px}ul ul,ol ul,ul ol,ol ol{margin-bottom:0}.list-unstyled{padding-left:0;list-style:none}.list-inline{padding-left:0;list-style:none;margin-left:-5px}.list-inline>li{display:inline-block;padding-left:5px;padding-right:5px}dl{margin-top:0;margin-bottom:20px}dt,dd{line-height:1.42857143}dt{font-weight:bold}dd{margin-left:0}@media (min-width:768px){.dl-horizontal dt{float:left;width:160px;clear:left;text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:180px}}abbr[title],abbr[data-original-title]{cursor:help;border-bottom:1px dotted #777}.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:10px 20px;margin:0 0 20px;font-size:17.5px;border-left:5px solid #eee}blockquote p:last-child,blockquote ul:last-child,blockquote ol:last-child{margin-bottom:0}blockquote footer,blockquote small,blockquote .small{display:block;font-size:80%;line-height:1.42857143;color:#777}blockquote footer:before,blockquote small:before,blockquote .small:before{content:'\2014 \00A0'}.blockquote-reverse,blockquote.pull-right{padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0;text-align:right}.blockquote-reverse footer:before,blockquote.pull-right footer:before,.blockquote-reverse small:before,blockquote.pull-right small:before,.blockquote-reverse .small:before,blockquote.pull-right .small:before{content:''}.blockquote-reverse footer:after,blockquote.pull-right footer:after,.blockquote-reverse small:after,blockquote.pull-right small:after,.blockquote-reverse .small:after,blockquote.pull-right .small:after{content:'\00A0 \2014'}address{margin-bottom:20px;font-style:normal;line-height:1.42857143}.container{margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px}@media (min-width:768px){.container{width:750px}}@media (min-width:992px){.container{width:970px}}@media (min-width:1200px){.container{width:1170px}}.container-fluid{margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px}.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12{float:left}.col-xs-11{width:91.66666667%}.col-xs-10{width:83.33333333%}.col-xs-9{width:75%}.col-xs-8{width:66.66666667%}.col-xs-7{width:58.33333333%}.col-xs-6{width:50%}.col-xs-5{width:41.66666667%}.col-xs-4{width:33.33333333%}.col-xs-3{width:25%}.col-xs-2{width:16.66666667%}.col-xs-1{width:8.33333333%}.col-xs-pull-12{right:100%}.col-xs-pull-11{right:91.66666667%}.col-xs-pull-10{right:83.33333333%}.col-xs-pull-9{right:75%}.col-xs-pull-8{right:66.66666667%}.col-xs-pull-7{right:58.33333333%}.col-xs-pull-6{right:50%}.col-xs-pull-5{right:41.66666667%}.col-xs-pull-4{right:33.33333333%}.col-xs-pull-3{right:25%}.col-xs-pull-2{right:16.66666667%}.col-xs-pull-1{right:8.33333333%}.col-xs-pull-0{right:auto}.col-xs-push-12{left:100%}.col-xs-push-11{left:91.66666667%}.col-xs-push-10{left:83.33333333%}.col-xs-push-9{left:75%}.col-xs-push-8{left:66.66666667%}.col-xs-push-7{left:58.33333333%}.col-xs-push-6{left:50%}.col-xs-push-5{left:41.66666667%}.col-xs-push-4{left:33.33333333%}.col-xs-push-3{left:25%}.col-xs-push-2{left:16.66666667%}.col-xs-push-1{left:8.33333333%}.col-xs-push-0{left:auto}.col-xs-offset-12{margin-left:100%}.col-xs-offset-11{margin-left:91.66666667%}.col-xs-offset-10{margin-left:83.33333333%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-8{margin-left:66.66666667%}.col-xs-offset-7{margin-left:58.33333333%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-5{margin-left:41.66666667%}.col-xs-offset-4{margin-left:33.33333333%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-2{margin-left:16.66666667%}.col-xs-offset-1{margin-left:8.33333333%}.col-xs-offset-0{margin-left:0}@media (min-width:768px){.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12{float:left}.col-sm-12{width:100%}.col-sm-11{width:91.66666667%}.col-sm-10{width:83.33333333%}.col-sm-9{width:75%}.col-sm-8{width:66.66666667%}.col-sm-7{width:58.33333333%}.col-sm-6{width:50%}.col-sm-5{width:41.66666667%}.col-sm-4{width:33.33333333%}.col-sm-3{width:25%}.col-sm-2{width:16.66666667%}.col-sm-1{width:8.33333333%}.col-sm-pull-12{right:100%}.col-sm-pull-11{right:91.66666667%}.col-sm-pull-10{right:83.33333333%}.col-sm-pull-9{right:75%}.col-sm-pull-8{right:66.66666667%}.col-sm-pull-7{right:58.33333333%}.col-sm-pull-6{right:50%}.col-sm-pull-5{right:41.66666667%}.col-sm-pull-4{right:33.33333333%}.col-sm-pull-3{right:25%}.col-sm-pull-2{right:16.66666667%}.col-sm-pull-1{right:8.33333333%}.col-sm-pull-0{right:auto}.col-sm-push-12{left:100%}.col-sm-push-11{left:91.66666667%}.col-sm-push-10{left:83.33333333%}.col-sm-push-9{left:75%}.col-sm-push-8{left:66.66666667%}.col-sm-push-7{left:58.33333333%}.col-sm-push-6{left:50%}.col-sm-push-5{left:41.66666667%}.col-sm-push-4{left:33.33333333%}.col-sm-push-3{left:25%}.col-sm-push-2{left:16.66666667%}.col-sm-push-1{left:8.33333333%}.col-sm-push-0{left:auto}.col-sm-offset-12{margin-left:100%}.col-sm-offset-11{margin-left:91.66666667%}.col-sm-offset-10{margin-left:83.33333333%}.col-sm-offset-9{margin-left:75%}.col-sm-offset-8{margin-left:66.66666667%}.col-sm-offset-7{margin-left:58.33333333%}.col-sm-offset-6{margin-left:50%}.col-sm-offset-5{margin-left:41.66666667%}.col-sm-offset-4{margin-left:33.33333333%}.col-sm-offset-3{margin-left:25%}.col-sm-offset-2{margin-left:16.66666667%}.col-sm-offset-1{margin-left:8.33333333%}.col-sm-offset-0{margin-left:0}}@media (min-width:992px){.col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12{float:left}.col-md-12{width:100%}.col-md-11{width:91.66666667%}.col-md-10{width:83.33333333%}.col-md-9{width:75%}.col-md-8{width:66.66666667%}.col-md-7{width:58.33333333%}.col-md-6{width:50%}.col-md-5{width:41.66666667%}.col-md-4{width:33.33333333%}.col-md-3{width:25%}.col-md-2{width:16.66666667%}.col-md-1{width:8.33333333%}.col-md-pull-12{right:100%}.col-md-pull-11{right:91.66666667%}.col-md-pull-10{right:83.33333333%}.col-md-pull-9{right:75%}.col-md-pull-8{right:66.66666667%}.col-md-pull-7{right:58.33333333%}.col-md-pull-6{right:50%}.col-md-pull-5{right:41.66666667%}.col-md-pull-4{right:33.33333333%}.col-md-pull-3{right:25%}.col-md-pull-2{right:16.66666667%}.col-md-pull-1{right:8.33333333%}.col-md-pull-0{right:auto}.col-md-push-12{left:100%}.col-md-push-11{left:91.66666667%}.col-md-push-10{left:83.33333333%}.col-md-push-9{left:75%}.col-md-push-8{left:66.66666667%}.col-md-push-7{left:58.33333333%}.col-md-push-6{left:50%}.col-md-push-5{left:41.66666667%}.col-md-push-4{left:33.33333333%}.col-md-push-3{left:25%}.col-md-push-2{left:16.66666667%}.col-md-push-1{left:8.33333333%}.col-md-push-0{left:auto}.col-md-offset-12{margin-left:100%}.col-md-offset-11{margin-left:91.66666667%}.col-md-offset-10{margin-left:83.33333333%}.col-md-offset-9{margin-left:75%}.col-md-offset-8{margin-left:66.66666667%}.col-md-offset-7{margin-left:58.33333333%}.col-md-offset-6{margin-left:50%}.col-md-offset-5{margin-left:41.66666667%}.col-md-offset-4{margin-left:33.33333333%}.col-md-offset-3{margin-left:25%}.col-md-offset-2{margin-left:16.66666667%}.col-md-offset-1{margin-left:8.33333333%}.col-md-offset-0{margin-left:0}}@media (min-width:1200px){.col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12{float:left}.col-lg-12{width:100%}.col-lg-11{width:91.66666667%}.col-lg-10{width:83.33333333%}.col-lg-9{width:75%}.col-lg-8{width:66.66666667%}.col-lg-7{width:58.33333333%}.col-lg-6{width:50%}.col-lg-5{width:41.66666667%}.col-lg-4{width:33.33333333%}.col-lg-3{width:25%}.col-lg-2{width:16.66666667%}.col-lg-1{width:8.33333333%}.col-lg-pull-12{right:100%}.col-lg-pull-11{right:91.66666667%}.col-lg-pull-10{right:83.33333333%}.col-lg-pull-9{right:75%}.col-lg-pull-8{right:66.66666667%}.col-lg-pull-7{right:58.33333333%}.col-lg-pull-6{right:50%}.col-lg-pull-5{right:41.66666667%}.col-lg-pull-4{right:33.33333333%}.col-lg-pull-3{right:25%}.col-lg-pull-2{right:16.66666667%}.col-lg-pull-1{right:8.33333333%}.col-lg-pull-0{right:auto}.col-lg-push-12{left:100%}.col-lg-push-11{left:91.66666667%}.col-lg-push-10{left:83.33333333%}.col-lg-push-9{left:75%}.col-lg-push-8{left:66.66666667%}.col-lg-push-7{left:58.33333333%}.col-lg-push-6{left:50%}.col-lg-push-5{left:41.66666667%}.col-lg-push-4{left:33.33333333%}.col-lg-push-3{left:25%}.col-lg-push-2{left:16.66666667%}.col-lg-push-1{left:8.33333333%}.col-lg-push-0{left:auto}.col-lg-offset-12{margin-left:100%}.col-lg-offset-11{margin-left:91.66666667%}.col-lg-offset-10{margin-left:83.33333333%}.col-lg-offset-9{margin-left:75%}.col-lg-offset-8{margin-left:66.66666667%}.col-lg-offset-7{margin-left:58.33333333%}.col-lg-offset-6{margin-left:50%}.col-lg-offset-5{margin-left:41.66666667%}.col-lg-offset-4{margin-left:33.33333333%}.col-lg-offset-3{margin-left:25%}.col-lg-offset-2{margin-left:16.66666667%}.col-lg-offset-1{margin-left:8.33333333%}.col-lg-offset-0{margin-left:0}}.clearfix:before,.clearfix:after,.dl-horizontal dd:before,.dl-horizontal dd:after,.container:before,.container:after,.container-fluid:before,.container-fluid:after,.row:before,.row:after{content:" ";display:table}.clearfix:after,.dl-horizontal dd:after,.container:after,.container-fluid:after,.row:after{clear:both}.center-block{display:block;margin-left:auto;margin-right:auto}.pull-right{float:right !important}.pull-left{float:left !important}.hide{display:none !important}.show{display:block !important}.invisible{visibility:hidden}.text-hide{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.hidden{display:none !important}.affix{position:fixed}@-ms-viewport{width:device-width}.visible-xs,.visible-sm,.visible-md,.visible-lg{display:none !important}.visible-xs-block,.visible-xs-inline,.visible-xs-inline-block,.visible-sm-block,.visible-sm-inline,.visible-sm-inline-block,.visible-md-block,.visible-md-inline,.visible-md-inline-block,.visible-lg-block,.visible-lg-inline,.visible-lg-inline-block{display:none !important}@media (max-width:767px){.visible-xs{display:block !important}table.visible-xs{display:table !important}tr.visible-xs{display:table-row !important}th.visible-xs,td.visible-xs{display:table-cell !important}}@media (max-width:767px){.visible-xs-block{display:block !important}}@media (max-width:767px){.visible-xs-inline{display:inline !important}}@media (max-width:767px){.visible-xs-inline-block{display:inline-block !important}}@media (min-width:768px) and (max-width:991px){.visible-sm{display:block !important}table.visible-sm{display:table !important}tr.visible-sm{display:table-row !important}th.visible-sm,td.visible-sm{display:table-cell !important}}@media (min-width:768px) and (max-width:991px){.visible-sm-block{display:block !important}}@media (min-width:768px) and (max-width:991px){.visible-sm-inline{display:inline !important}}@media (min-width:768px) and (max-width:991px){.visible-sm-inline-block{display:inline-block !important}}@media (min-width:992px) and (max-width:1199px){.visible-md{display:block !important}table.visible-md{display:table !important}tr.visible-md{display:table-row !important}th.visible-md,td.visible-md{display:table-cell !important}}@media (min-width:992px) and (max-width:1199px){.visible-md-block{display:block !important}}@media (min-width:992px) and (max-width:1199px){.visible-md-inline{display:inline !important}}@media (min-width:992px) and (max-width:1199px){.visible-md-inline-block{display:inline-block !important}}@media (min-width:1200px){.visible-lg{display:block !important}table.visible-lg{display:table !important}tr.visible-lg{display:table-row !important}th.visible-lg,td.visible-lg{display:table-cell !important}}@media (min-width:1200px){.visible-lg-block{display:block !important}}@media (min-width:1200px){.visible-lg-inline{display:inline !important}}@media (min-width:1200px){.visible-lg-inline-block{display:inline-block !important}}@media (max-width:767px){.hidden-xs{display:none !important}}@media (min-width:768px) and (max-width:991px){.hidden-sm{display:none !important}}@media (min-width:992px) and (max-width:1199px){.hidden-md{display:none !important}}@media (min-width:1200px){.hidden-lg{display:none !important}}.visible-print{display:none !important}@media print{.visible-print{display:block !important}table.visible-print{display:table !important}tr.visible-print{display:table-row !important}th.visible-print,td.visible-print{display:table-cell !important}}.visible-print-block{display:none !important}@media print{.visible-print-block{display:block !important}}.visible-print-inline{display:none !important}@media print{.visible-print-inline{display:inline !important}}.visible-print-inline-block{display:none !important}@media print{.visible-print-inline-block{display:inline-block !important}}@media print{.hidden-print{display:none !important}} \ No newline at end of file diff --git a/views/images/pizza.png b/views/images/pizza.png index 60a19ca8c08..2244fda3054 100644 Binary files a/views/images/pizza.png and b/views/images/pizza.png differ diff --git a/views/images/pizzeria.jpg b/views/images/pizzeria.jpg index 129338882f6..5140bf21856 100644 Binary files a/views/images/pizzeria.jpg and b/views/images/pizzeria.jpg differ diff --git a/views/images/pizzeria_top.jpg b/views/images/pizzeria_top.jpg new file mode 100644 index 00000000000..5418abfb110 Binary files /dev/null and b/views/images/pizzeria_top.jpg differ diff --git a/views/js/main.js b/views/js/main.js index 82409e8ab61..42fd9750979 100644 --- a/views/js/main.js +++ b/views/js/main.js @@ -16,6 +16,35 @@ Cameron Pittman, Udacity Course Developer cameron *at* udacity *dot* com */ +//Steps taken by Greg Bopp to de-jankify the pizza site +//Original site netted about 2-2.5fps +// 1) Scaled down and compressed pizza.png. Scaled down to 77x100px since that is the size of the background pizzas. + //Used http://compresspng.com/ to compress the original size of the pizza.png image from 49kb to 5kb + //got to about 3-3.5fps +// 2) Reduce the number of pizzas being generated from 200 to 24. We will realign the vertical positions to match the users display. + // No need to have more than 3 rows of random flying pizza on a screen at a time. + // Got to about 12-15 fps +// 3) Removed the "updatePostions" inside of: document.addEventListener('DOMContentLoaded', function() { + // Got to about 15-20fps//added this back in on 5/12/17 +// 4) Made the updatePositions function more efficient by simplifying / changing the following code: + // Chanaged className to classList + // Utilized requestAnimationFrame to only update the pizza positions when we can and not with every scroll / mouse down event + // Utilized style.transform and translateX to update the Xpos of the sliding pizza bg. + // This required a simple update in pizza.html where the #movingPizzas1 div was changed to col-md-12 and it is not inside of a row. +// 5) Made efficiency improvements to the pizza slider and random generated pizzas: + // Simplified the determineDx function. ignoring the windowWdth, simplified the sizes to just be 3 fixed sizes when the pizza slider is used. + // Did away with the percentages in sizeSwitcher and simplified the math. Now it is just a simple subtract the old width from the new width + // and then apply the changes to all of the random pizza pics. + // Completely removed the use of "document.querySelectorAll(".randomPizzaContainer")" calls by utilizing getElementsByClassName + // and querySelector. + // Created a variable named numOfPizzas to store the correct number of random pizzas generated. + // Also, took as much math out of the changePizzaSizes for loop as possible. It is now just one line that applies + // the size changes to each of the random pizza entries. +// 6) Utilized + + + + // As you may have realized, this website randomly generates pizzas. // Here are arrays of all possible pizza ingredients. var pizzaIngredients = {}; @@ -373,18 +402,16 @@ var pizzaElementGenerator = function(i) { pizzaDescriptionContainer = document.createElement("div"); pizzaContainer.classList.add("randomPizzaContainer"); - pizzaContainer.style.width = "33.33%"; - pizzaContainer.style.height = "325px"; + pizzaImageContainer.classList.add("randomPizzaPic"); pizzaContainer.id = "pizza" + i; // gives each pizza element a unique id - pizzaImageContainer.style.width="35%"; pizzaImage.src = "images/pizza.png"; pizzaImage.classList.add("img-responsive"); pizzaImageContainer.appendChild(pizzaImage); pizzaContainer.appendChild(pizzaImageContainer); - - pizzaDescriptionContainer.style.width="65%"; + pizzaDescriptionContainer.classList.add("randomPizzaEntry"); + //pizzaDescriptionContainer.classList.add("col-md-7"); pizzaName = document.createElement("h4"); pizzaName.innerHTML = randomName(); @@ -406,13 +433,13 @@ var resizePizzas = function(size) { function changeSliderLabel(size) { switch(size) { case "1": - document.querySelector("#pizzaSize").innerHTML = "Small"; + document.querySelector("#pizzaSize").innerHTML = "

Small

"; return; case "2": - document.querySelector("#pizzaSize").innerHTML = "Medium"; + document.querySelector("#pizzaSize").innerHTML = "

Medium

"; return; case "3": - document.querySelector("#pizzaSize").innerHTML = "Large"; + document.querySelector("#pizzaSize").innerHTML = "

Large

"; return; default: console.log("bug in changeSliderLabel"); @@ -421,58 +448,60 @@ var resizePizzas = function(size) { changeSliderLabel(size); - // Returns the size difference to change a pizza element from one size to another. Called by changePizzaSlices(size). - function determineDx (elem, size) { - var oldWidth = elem.offsetWidth; - var windowWidth = document.querySelector("#randomPizzas").offsetWidth; - var oldSize = oldWidth / windowWidth; - - // Changes the slider value to a percent width - function sizeSwitcher (size) { - switch(size) { - case "1": - return 0.25; - case "2": - return 0.3333; - case "3": - return 0.5; - default: - console.log("bug in sizeSwitcher"); - } + var numOfPizzas = document.getElementsByClassName("randomPizzaContainer").length; + + // Changes the slider value to a percent width + function sizeSwitcher (size) { + switch(size) { + case "1": + return 77; + case "2": + return 177; + case "3": + return 277; + default: + console.log("bug in sizeSwitcher"); } + } - var newSize = sizeSwitcher(size); - var dx = (newSize - oldSize) * windowWidth; + var newSize = sizeSwitcher(size)+"px"; - return dx; - } - // Iterates through pizza elements on the page and changes their widths - function changePizzaSizes(size) { - for (var i = 0; i < document.querySelectorAll(".randomPizzaContainer").length; i++) { - var dx = determineDx(document.querySelectorAll(".randomPizzaContainer")[i], size); - var newwidth = (document.querySelectorAll(".randomPizzaContainer")[i].offsetWidth + dx) + 'px'; - document.querySelectorAll(".randomPizzaContainer")[i].style.width = newwidth; + // Iterates through pizza elements on the page and changes the widths + function newPizzaSizes() { + for (var i = 0; i < numOfPizzas; i++) { + document.getElementsByClassName("randomPizzaPic")[i].style.width = newSize; } - } - changePizzaSizes(size); + }; + + newPizzaSizes(); // User Timing API is awesome window.performance.mark("mark_end_resize"); window.performance.measure("measure_pizza_resize", "mark_start_resize", "mark_end_resize"); var timeToResize = window.performance.getEntriesByName("measure_pizza_resize"); console.log("Time to resize pizzas: " + timeToResize[timeToResize.length-1].duration + "ms"); + }; window.performance.mark("mark_start_generating"); // collect timing data + // This for-loop actually creates and appends all of the pizzas when the page loads +// Removed the pizzasDiv variable from the for loop +var pizzasDiv = document.getElementById("randomPizzas"); +// Utilizing createDocumentFragment to boost performance +var pizzasDivFrag = document.createDocumentFragment(); + for (var i = 2; i < 100; i++) { - var pizzasDiv = document.getElementById("randomPizzas"); - pizzasDiv.appendChild(pizzaElementGenerator(i)); + //pizzasDiv.appendChild(pizzaElementGenerator(i)); + pizzasDivFrag.appendChild(pizzaElementGenerator(i)); } +pizzasDiv.appendChild(pizzasDivFrag); + + // User Timing API again. These measurements tell you how long it took to generate the initial pizzas window.performance.mark("mark_end_generating"); window.performance.measure("measure_pizza_generation", "mark_start_generating", "mark_end_generating"); @@ -493,6 +522,28 @@ function logAverageFrame(times) { // times is the array of User Timing measure console.log("Average scripting time to generate last 10 frames: " + sum / 10 + "ms"); } +//Incorporating requestAnimationFrame into our sliding pizzas +/** + * Callback for our scroll event - just + * keeps track of the last scroll value + */ +function onScroll() { + lastScrollY = window.scrollY; + requestTick(); +} + +/** + * Calls rAF if it's not already + * been done already + */ +function requestTick() { + if(!ticking) { + requestAnimationFrame(updatePositions); + ticking = true; + } +} + + // The following code for sliding background pizzas was pulled from Ilya's demo found at: // https://www.igvita.com/slides/2012/devtools-tips-and-tricks/jank-demo.html @@ -500,11 +551,30 @@ function logAverageFrame(times) { // times is the array of User Timing measure function updatePositions() { frame++; window.performance.mark("mark_start_frame"); - - var items = document.querySelectorAll('.mover'); - for (var i = 0; i < items.length; i++) { - var phase = Math.sin((document.body.scrollTop / 1250) + (i % 5)); - items[i].style.left = items[i].basicLeft + 100 * phase + 'px'; + var items = document.querySelectorAll('.mover'), + //moved some of the math outside of the for loop for efficiency + distanceToTop = (document.body.scrollTop / 1250), + newXPos = []; + + // first for loop calculates all of the new positions for the bg pizzas + for (var i = 0; i < 24; i++) { + //var phase = Math.sin((document.body.scrollTop / 1250) + (i % 5)); //Original code + var phase = Math.sin((distanceToTop) + (i % 5)); + //items[i].style.left = items[i].basicLeft + 100 * phase + 'px'; + newXPos[i] = items[i].basicLeft + 100 * phase + 'px'; + } + // second for loop moves the bg pizzas to the new locations + // thanks to Paul Lewis AGAIN for a great tutorial on why I should use style.transform instead of style.left + // https://www.html5rocks.com/en/tutorials/speed/high-performance-animations/ + // And thanks to java2s for showing me that I need to consider multiple browsers: + // http://www.java2s.com/Tutorials/Javascript/Buildin_Object/Style/Style_transform.htm + for (var i = 0; i < 24; i++) { + // Code for Chrome, Safari, Opera + items[i].style.WebkitTransform = "translateX("+newXPos[i]+") translateZ(0)"; + // Code for IE9 + items[i].style.msTransform = "translateX("+newXPos[i]+") translateZ(0)"; + // Standard syntax + items[i].style.transform = "translateX("+newXPos[i]+") translateZ(0)"; } // User Timing API to the rescue again. Seriously, it's worth learning. @@ -515,24 +585,37 @@ function updatePositions() { var timesToUpdatePosition = window.performance.getEntriesByName("measure_frame_duration"); logAverageFrame(timesToUpdatePosition); } + // allow further rAFs to be called + ticking = false; } // runs updatePositions on scroll -window.addEventListener('scroll', updatePositions); +//window.addEventListener('scroll', updatePositions); //Original Code +// runs the function named onScroll on Scroll +window.addEventListener('scroll', onScroll, false); //new code // Generates the sliding pizzas when the page loads. document.addEventListener('DOMContentLoaded', function() { + ticking = false; var cols = 8; - var s = 256; - for (var i = 0; i < 200; i++) { + // var s = 256; //original code + // since we only have 3 rows of pizza we want to position the 3 rows equally centered on the users screen + var displayHeight = window.innerHeight; + var rowHeight = (displayHeight/3); + var rowYpos = ((rowHeight/2)-50); + var elemFrag = document.createDocumentFragment(); + for (var i = 0; i < 24; i++) { // Reducing the number from 200 to 24 to increase frame rate var elem = document.createElement('img'); - elem.className = 'mover'; + //elem.className = 'mover'; //original code + elem.classList.add('mover'); //updated code elem.src = "images/pizza.png"; - elem.style.height = "100px"; - elem.style.width = "73.333px"; - elem.basicLeft = (i % cols) * s; - elem.style.top = (Math.floor(i / cols) * s) + 'px'; - document.querySelector("#movingPizzas1").appendChild(elem); + //elem.style.height = "100px"; + //elem.style.width = "77px"; + elem.basicLeft = (i % cols) * rowHeight; + elem.style.top = ((Math.floor(i / cols) * rowHeight) + rowYpos)+ 'px'; + elemFrag.appendChild(elem); } - updatePositions(); + //updatePositions(); //original code + document.querySelector("#movingPizzas1").appendChild(elemFrag); + requestTick(); }); diff --git a/views/pizza.html b/views/pizza.html index 246b51eda6e..f5bfd57ac47 100644 --- a/views/pizza.html +++ b/views/pizza.html @@ -1,44 +1,170 @@ - - + + + + + +
+
-
-
-
- +
+
-
+

We Have Hundreds of Pizza Recipes!

@@ -56,7 +182,7 @@

We Have Hundreds of Pizza Recipes!

-
+
@@ -74,9 +200,9 @@

Ingredients!

-
+
-

Locations!

+

Locations!

Pizza Road

@@ -89,56 +215,86 @@

Classic Pie Way

-
-
-

Our Pizzas!

-
-
- What size pizza would you like? Use the slider below to change pizza sizes. -
-
Medium
-
- -
+ +
+ +
+
+

Our Pizzas!

-
-
-
- -
-
-

The Udacity Special

-
    -
  • Turkey
  • -
  • Tofu
  • -
  • Cauliflower
  • -
  • Sun Dried Tomatoes
  • -
  • Velveeta Cheese
  • -
  • Red Sauce
  • -
  • Whole Wheat Crust
  • -
-
-
-
-
- -
-
-

The Cameron Special

-
    -
  • Chicken
  • -
  • Hot Sauce
  • -
  • White Crust
  • -
-
-
+
+
+
+ What size pizza would you like? Use the slider below to change pizza sizes.
-
- +
+

Small

+
+
+
+ +
+
+ +
+
+
+ +
+
+

The Udacity Special

+
    +
  • Turkey
  • +
  • Tofu
  • +
  • Cauliflower
  • +
  • Sun Dried Tomatoes
  • +
  • Velveeta Cheese
  • +
  • Red Sauce
  • +
  • Whole Wheat Crust
  • +
+
+
+
+
+ +
+
+

The Cameron Special

+
    +
  • Chicken
  • +
  • Hot Sauce
  • +
  • White Crust
  • +
+
+
+
+
+ +
+ +
+
- + - + + + + + + + +