├── .npmignore ├── .gitignore ├── .github └── CODEOWNERS ├── .travis.yml ├── bower.json ├── test ├── unset-test.js ├── buster.js ├── style.css ├── helpers.js ├── set-test.js ├── test.html └── calc-test.js ├── GruntFile.js ├── LICENSE-MIT ├── package.json ├── examples ├── 1 │ ├── style.css │ └── index.html └── single-line │ └── index.html ├── README.md └── lib └── index.js /.npmignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Guessed from commit history 2 | * @Financial-Times/apps 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | script: 2 | - "npm test" 3 | 4 | language: node_js 5 | 6 | node_js: 7 | - "6" 8 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ftellipsis", 3 | "main": "lib/index.js", 4 | "repository": { 5 | "type": "git", 6 | "url": "git://github.com/ftlabs/ftellipsis.git" 7 | }, 8 | "ignore": [ 9 | "examples/", 10 | "test/" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /test/unset-test.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | buster.testCase("Ellipsis#unset()", { 4 | setUp: function(done) { 5 | helpers.injectElement(this, done); 6 | }, 7 | 8 | "Should restore the ellipsis element and it's contents back to how it was before .set()": function() { 9 | var ellip = new Ellipsis(this.el); 10 | var clamped = this.el.children[2]; 11 | var naturalHeight = clamped.clientHeight; 12 | 13 | ellip 14 | .calc() 15 | .set(); 16 | 17 | assert.equals(clamped.clientHeight, 20); 18 | 19 | ellip.unset(); 20 | 21 | assert.equals(clamped.clientHeight, naturalHeight); 22 | }, 23 | 24 | tearDown: function(done) { 25 | helpers.destroyElement(this.el, done); 26 | } 27 | }); -------------------------------------------------------------------------------- /test/buster.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module Dependencies 4 | */ 5 | 6 | var fs = require('fs'); 7 | var config = module.exports; 8 | 9 | config["My tests"] = { 10 | env: "browser", // or "node" 11 | rootPath: "../", 12 | autoRun: false, 13 | sources: [ 14 | "node_modules/superagent/superagent.js", 15 | "test/helpers.js", 16 | "lib/*.js" // Glob patterns supported 17 | ], 18 | tests: [ 19 | "test/*-test.js" 20 | ], 21 | resources: [ 22 | { 23 | path: 'test.html', 24 | content: fs.readFileSync('test/test.html') 25 | }, 26 | { 27 | path: 'test/style.css', 28 | file: 'test/style.css' 29 | } 30 | ] 31 | }; -------------------------------------------------------------------------------- /test/style.css: -------------------------------------------------------------------------------- 1 | 2 | .container { 3 | position: relative; 4 | width: 400px; 5 | height: 190px; 6 | font-size: 13px; 7 | line-height: 20px; 8 | font-family: arial; 9 | } 10 | 11 | .container p { 12 | margin: 0; 13 | text-indent: 1em; 14 | font-size: 13px; 15 | line-height: 20px; 16 | } 17 | 18 | .container-1 { 19 | -webkit-column-count: 1; 20 | -moz-column-count: 1; 21 | -ms-column-count: 1; 22 | column-count: 1; 23 | } 24 | 25 | .container-2 { 26 | -webkit-column-count: 2; 27 | -moz-column-count: 2; 28 | -ms-column-count: 2; 29 | column-count: 2; 30 | } 31 | 32 | .container-3 { 33 | -webkit-column-count: 3; 34 | -moz-column-count: 3; 35 | -ms-column-count: 3; 36 | column-count: 3; 37 | } -------------------------------------------------------------------------------- /GruntFile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | 3 | // Project configuration. 4 | grunt.initConfig({ 5 | pkg: grunt.file.readJSON('package.json'), 6 | 7 | buster: { 8 | test: { 9 | config: 'test/buster.js', 10 | }, 11 | }, 12 | 13 | readme: { 14 | build: { 15 | code: [ 16 | { path: 'lib/index.js' } 17 | ], 18 | output: { 19 | 'docs/readme.hogan': 'README.md' 20 | } 21 | } 22 | }, 23 | uglify: { 24 | build: { 25 | src: 'lib/index.js', 26 | dest: 'build/<%= pkg.name %>.min.js' 27 | } 28 | } 29 | }); 30 | 31 | grunt.loadNpmTasks('grunt-buster'); 32 | grunt.loadNpmTasks('grunt-contrib-uglify'); 33 | grunt.loadNpmTasks('grunt-readme'); 34 | 35 | // Default task. 36 | grunt.registerTask('default', ['uglify', 'readme']); 37 | }; 38 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 The Financial Times Ltd. 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ftellipsis", 3 | "title": "FTEllipsis", 4 | "description": "Multi-line ellipsis made possible", 5 | "version": "0.2.3", 6 | "homepage": "https://github.com/ftlabs/ftellipsis", 7 | "main": "lib/index.js", 8 | "repository": { 9 | "type": "git", 10 | "url": "git://github.com:ftlabs/ftellipsis.git" 11 | }, 12 | "author": { 13 | "name": "Wilson Page", 14 | "email": "wilsonpage@me.com", 15 | "github": "wilsonpage", 16 | "organization": "The Finanacial Times Limited" 17 | }, 18 | "licenses": [ 19 | { 20 | "type": "MIT", 21 | "url": "https://github.com/ftlabs/ftellipsis/blob/master/LICENSE-MIT" 22 | } 23 | ], 24 | "dependencies": {}, 25 | "devDependencies": { 26 | "grunt": "~0.4.5", 27 | "grunt-readme": "git://github.com/wilsonpage/grunt-readme.git", 28 | "grunt-contrib-uglify": "~0.2.0", 29 | "grunt-contrib-watch": "~0.5.1", 30 | "buster": "~0.7", 31 | "buster-assertions": "~0.10.4", 32 | "superagent": "0.14.4", 33 | "grunt-buster": "~0.3.1", 34 | "grunt-cli": "~0.1.8", 35 | "phantomjs": "^2" 36 | }, 37 | "keywords": [ 38 | "ellipsis", 39 | "css", 40 | "layout" 41 | ], 42 | "scripts": { 43 | "test": "./node_modules/.bin/grunt buster -v" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test/helpers.js: -------------------------------------------------------------------------------- 1 | var helpers = {}; 2 | var request = superagent; 3 | 4 | var assert = buster.referee.assert; 5 | var refute = buster.referee.refute; 6 | 7 | helpers.fixture = function(name, callback) { 8 | request.get(name, function(res) { 9 | callback(res.text); 10 | }); 11 | }; 12 | 13 | helpers.element = function(name, callback) { 14 | helpers.fixture(name, function(text) { 15 | var parent = document.createElement('div'); 16 | parent.innerHTML = text; 17 | callback(parent.removeChild(parent.firstElementChild)); 18 | }); 19 | }; 20 | 21 | helpers.injectElement = function(test, callback) { 22 | helpers.element('test.html', function(el) { 23 | test.el = el; 24 | document.body.insertBefore(el, document.body.firstElementChild); 25 | var forceRender = el.offsetTop; 26 | callback(); 27 | }); 28 | }; 29 | 30 | helpers.destroyElement = function(el, callback) { 31 | el.parentNode.removeChild(el); 32 | callback(); 33 | }; 34 | 35 | function loadStylesheet(url, callback) { 36 | var head = document.getElementsByTagName("head")[0]; 37 | var body = document.body; 38 | var css = document.createElement("link"); 39 | var img = document.createElement("img"); 40 | 41 | css.href = url; 42 | css.rel = "stylesheet"; 43 | head.appendChild(css); 44 | 45 | img.onerror = function() { 46 | body.removeChild(img); 47 | callback(); 48 | }; 49 | 50 | body.appendChild(img); 51 | img.src = url; 52 | } 53 | 54 | loadStylesheet('test/style.css', buster.run); 55 | -------------------------------------------------------------------------------- /examples/1/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | box-sizing: border-box; 4 | } 5 | 6 | html, 7 | body { 8 | height: 100%; 9 | } 10 | 11 | h1 { 12 | font-size: inherit; 13 | } 14 | 15 | p { 16 | break-before: avoid; 17 | } 18 | 19 | 20 | 21 | .ellipsis-overflowing-child { 22 | margin-bottom: 9em; 23 | padding: 0 !important; 24 | position: relative; 25 | } 26 | 27 | .ellipsis-overflowing-child .ellipsis-helper { 28 | width: 8em; 29 | background: -moz-linear-gradient(left, rgba(221,221,221,0) 0%, rgba(221,221,221,1) 100%); /* FF3.6+ */ 30 | background: -o-linear-gradient(left, rgba(221,221,221,0) 0%,rgba(221,221,221,1) 100%); /* Opera 11.10+ */ 31 | background: -ms-linear-gradient(left, rgba(221,221,221,0) 0%,rgba(221,221,221,1) 100%); /* IE10+ */ 32 | background: linear-gradient(to right, rgba(221,221,221,0) 0%,rgba(221,221,221,1) 100%); /* W3C */ 33 | background: red; 34 | } 35 | 36 | .ellipsis-overflowing-child .ellipsis-helper:after { 37 | content: "..."; 38 | float: right; 39 | padding-right: 0.4em; 40 | } 41 | 42 | .container { 43 | height: 33.3333%; 44 | position: relative; 45 | font-size: 13px; 46 | line-height: 20px; 47 | background-color: #DDD; 48 | overflow: hidden; 49 | } 50 | 51 | .container-1 { 52 | -webkit-column-count: 1; 53 | -moz-column-count: 1; 54 | -ms-column-count: 1; 55 | column-count: 1; 56 | } 57 | 58 | .container-2 { 59 | -webkit-column-count: 2; 60 | -moz-column-count: 2; 61 | -ms-column-count: 2; 62 | column-count: 2; 63 | } 64 | 65 | .container-3 { 66 | -webkit-column-count: 3; 67 | -moz-column-count: 4; 68 | -ms-column-count: 3; 69 | column-count: 3; 70 | } 71 | 72 | /*.overflowing-child:after { 73 | content: "..."; 74 | }*/ -------------------------------------------------------------------------------- /test/set-test.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | buster.testCase("Ellipsis#set()", { 4 | setUp: function(done) { 5 | helpers.injectElement(this, done); 6 | }, 7 | 8 | "The overflowing child must have its height set": function() { 9 | var ellip = new Ellipsis(this.el); 10 | 11 | this.el.className += ' container-1'; 12 | 13 | ellip 14 | .calc() 15 | .set(); 16 | 17 | assert.equals(ellip.child.el.style.height, ellip.child.clampedHeight + 'px'); 18 | }, 19 | 20 | "All elements after the overflowing child should be hidden": function() { 21 | var ellip = new Ellipsis(this.el); 22 | 23 | this.el.className += ' container-1'; 24 | 25 | ellip 26 | .calc() 27 | .set(); 28 | 29 | assert.equals(this.el.children[3].style.display, 'none'); 30 | assert.equals(this.el.children[4].style.display, 'none'); 31 | }, 32 | 33 | "If a container is specified it should be marked after ellipsis has been set": function() { 34 | this.ellip = new Ellipsis(this.el, { container: document.body }); 35 | 36 | this.el.className += ' container-1'; 37 | 38 | this.ellip 39 | .calc() 40 | .set(); 41 | 42 | assert(document.body.classList.contains('ellipsis-set')); 43 | }, 44 | 45 | 46 | "Should appear completely collapsed if there is not enough room for one line": function() { 47 | this.ellip = new Ellipsis(this.el); 48 | 49 | this.el.className += ' container-3'; 50 | this.el.style.height = '10px'; 51 | 52 | this.ellip 53 | .calc() 54 | .set(); 55 | 56 | assert.equals(this.ellip.child.el.style.overflow, 'hidden'); 57 | assert.equals(this.ellip.child.el.clientHeight, 0); 58 | }, 59 | 60 | "Should not not clamp any child element if there is enough room for all the content": function() { 61 | this.ellip = new Ellipsis(this.el); 62 | 63 | this.el.className += ' container-2'; 64 | this.el.style.width = '820px'; 65 | this.el.style.height = '600px'; 66 | 67 | this.ellip.calc().set(); 68 | 69 | var clampedEl = this.el.querySelector('.ellipsis-overflowing-child'); 70 | 71 | assert.equals(clampedEl, null); 72 | }, 73 | 74 | tearDown: function(done) { 75 | if (this.ellip) this.ellip.unset().destroy(); 76 | helpers.destroyElement(this.el, done); 77 | } 78 | }); -------------------------------------------------------------------------------- /test/test.html: -------------------------------------------------------------------------------- 1 |
One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections.
3 |The bedding was hardly able to cover it and seemed ready to slide off any moment. His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. "What's happened to me? " he thought. It wasn't a dream.
4 |His room, a proper human room although a little too small, lay peacefully between its four familiar walls. A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer. Gregor then turned to look out the window at the dull weather. Drops of rain could be heard hitting the pane, which made him feel quite sad. "How about if I sleep a little bit longer and forget all this nonsense", he thought, but that was something he was unable to do because he was used to sleeping on his right, and in his present state couldn't get into that position. However hard he threw himself onto his right, he always rolled back to where he was.
5 |He must have tried it a hundred times, shut his eyes so that he wouldn't have to look at the floundering legs, and only stopped when he began to feel a mild, dull pain there that he had never felt before. "Oh, God", he thought, "what a strenuous career it is that I've chosen! Travelling day in and day out. Doing business like this takes much more effort than doing your own business at home, and on top of that there's the curse of travelling, worries about making train connections, bad and irregular food, contact with different people all the time so that you can never get to know anyone or become friendly with them. It can all go to Hell!"
6 |He felt a slight itch up on his belly; pushed himself slowly up on his back towards the headboard so that he could lift his head better; found where the itch was, and saw that it was covered with lots of little white spots which he didn't know what to make of; and when he tried to feel the place with one of his legs he drew it quickly back because as soon as he touched it he was overcome by a cold shudder. He slid back into his former position. "Getting up early all the time", he thought, "it makes you stupid. You've got to get enough sleep. Other travelling salesmen live a life of luxury. For instance, whenever I go back to the guest house during the morning to copy out the contract, these gentlemen are always still sitting there eating their breakfasts. I ought to just try that with my boss; I'd get kicked out on the spot. But who knows, maybe that would be the best thing for me."
7 |`s). 45 | 46 | ### Unsetting 47 | 48 | Unsetting an ellipsis instance removes any styling. 49 | 50 | ```js 51 | ellipsis.unset(); 52 | ``` 53 | 54 | ### Destroying 55 | 56 | Destroying an ellipsis instance resets the instance back to it's original state, unsetting internal variables and state. 57 | 58 | ```js 59 | ellipsis.destroy(); 60 | ``` 61 | 62 | ## Tests 63 | 64 | ``` 65 | $ npm install 66 | $ npm test 67 | ``` 68 | 69 | ## API 70 | 71 | ### Ellipsis(); 72 | 73 | Initialize a new Ellipsis 74 | instance with the given element. 75 | 76 | Options: 77 | 78 | - `container` A parent container element 79 | - `reRender` Forces a redraw after ellipsis applied 80 | 81 | ### Ellipsis#calc(); 82 | 83 | Measures the element and 84 | finds the overflowing child. 85 | 86 | 87 | 88 | ### Ellipsis#set(); 89 | 90 | Clamps the overflowing child using 91 | the information acquired from #calc(). 92 | 93 | 94 | 95 | ### Ellipsis#unset(); 96 | 97 | Unclamps the overflowing child. 98 | 99 | 100 | 101 | ### Ellipsis#destroy(); 102 | 103 | Clears any references 104 | 105 | 106 | 107 | 108 | ## Credits and collaboration 109 | 110 | The lead developer of FTEllipsis is [Wilson Page](http://github.com/wilsonpage) at FT Labs. All open source code released by FT Labs is licenced under the MIT licence. We welcome comments, feedback and suggestions. Please feel free to raise an issue or pull request. Enjoy... -------------------------------------------------------------------------------- /examples/single-line/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections.
27 |The bedding was hardly able to cover it and seemed ready to slide off any moment. His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. "What's happened to me? " he thought. It wasn't a dream.
28 |His room, a proper human room although a little too small, lay peacefully between its four familiar walls. A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer. Gregor then turned to look out the window at the dull weather. Drops of rain could be heard hitting the pane, which made him feel quite sad. "How about if I sleep a little bit longer and forget all this nonsense", he thought, but that was something he was unable to do because he was used to sleeping on his right, and in his present state couldn't get into that position. However hard he threw himself onto his right, he always rolled back to where he was.
29 |He must have tried it a hundred times, shut his eyes so that he wouldn't have to look at the floundering legs, and only stopped when he began to feel a mild, dull pain there that he had never felt before. "Oh, God", he thought, "what a strenuous career it is that I've chosen! Travelling day in and day out. Doing business like this takes much more effort than doing your own business at home, and on top of that there's the curse of travelling, worries about making train connections, bad and irregular food, contact with different people all the time so that you can never get to know anyone or become friendly with them. It can all go to Hell!"
30 |He felt a slight itch up on his belly; pushed himself slowly up on his back towards the headboard so that he could lift his head better; found where the itch was, and saw that it was covered with lots of little white spots which he didn't know what to make of; and when he tried to feel the place with one of his legs he drew it quickly back because as soon as he touched it he was overcome by a cold shudder. He slid back into his former position. "Getting up early all the time", he thought, "it makes you stupid. You've got to get enough sleep. Other travelling salesmen live a life of luxury. For instance, whenever I go back to the guest house during the morning to copy out the contract, these gentlemen are always still sitting there eating their breakfasts. I ought to just try that with my boss; I'd get kicked out on the spot. But who knows, maybe that would be the best thing for me."
31 |One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections.
13 |The bedding was hardly able to cover it and seemed ready to slide off any moment. His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. "What's happened to me? " he thought. It wasn't a dream.
14 |His room, a proper human room although a little too small, lay peacefully between its four familiar walls. A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer. Gregor then turned to look out the window at the dull weather. Drops of rain could be heard hitting the pane, which made him feel quite sad. "How about if I sleep a little bit longer and forget all this nonsense", he thought, but that was something he was unable to do because he was used to sleeping on his right, and in his present state couldn't get into that position. However hard he threw himself onto his right, he always rolled back to where he was.
15 |He must have tried it a hundred times, shut his eyes so that he wouldn't have to look at the floundering legs, and only stopped when he began to feel a mild, dull pain there that he had never felt before. "Oh, God", he thought, "what a strenuous career it is that I've chosen! Travelling day in and day out. Doing business like this takes much more effort than doing your own business at home, and on top of that there's the curse of travelling, worries about making train connections, bad and irregular food, contact with different people all the time so that you can never get to know anyone or become friendly with them. It can all go to Hell!"
16 |He felt a slight itch up on his belly; pushed himself slowly up on his back towards the headboard so that he could lift his head better; found where the itch was, and saw that it was covered with lots of little white spots which he didn't know what to make of; and when he tried to feel the place with one of his legs he drew it quickly back because as soon as he touched it he was overcome by a cold shudder. He slid back into his former position. "Getting up early all the time", he thought, "it makes you stupid. You've got to get enough sleep. Other travelling salesmen live a life of luxury. For instance, whenever I go back to the guest house during the morning to copy out the contract, these gentlemen are always still sitting there eating their breakfasts. I ought to just try that with my boss; I'd get kicked out on the spot. But who knows, maybe that would be the best thing for me."
17 |One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections.
22 |The bedding was hardly able to cover it and seemed ready to slide off any moment. His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. "What's happened to me? " he thought. It wasn't a dream.
23 |His room, a proper human room although a little too small, lay peacefully between its four familiar walls. A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer. Gregor then turned to look out the window at the dull weather. Drops of rain could be heard hitting the pane, which made him feel quite sad. "How about if I sleep a little bit longer and forget all this nonsense", he thought, but that was something he was unable to do because he was used to sleeping on his right, and in his present state couldn't get into that position. However hard he threw himself onto his right, he always rolled back to where he was.
24 |He must have tried it a hundred times, shut his eyes so that he wouldn't have to look at the floundering legs, and only stopped when he began to feel a mild, dull pain there that he had never felt before. "Oh, God", he thought, "what a strenuous career it is that I've chosen! Travelling day in and day out. Doing business like this takes much more effort than doing your own business at home, and on top of that there's the curse of travelling, worries about making train connections, bad and irregular food, contact with different people all the time so that you can never get to know anyone or become friendly with them. It can all go to Hell!"
25 |He felt a slight itch up on his belly; pushed himself slowly up on his back towards the headboard so that he could lift his head better; found where the itch was, and saw that it was covered with lots of little white spots which he didn't know what to make of; and when he tried to feel the place with one of his legs he drew it quickly back because as soon as he touched it he was overcome by a cold shudder. He slid back into his former position. "Getting up early all the time", he thought, "it makes you stupid. You've got to get enough sleep. Other travelling salesmen live a life of luxury. For instance, whenever I go back to the guest house during the morning to copy out the contract, these gentlemen are always still sitting there eating their breakfasts. I ought to just try that with my boss; I'd get kicked out on the spot. But who knows, maybe that would be the best thing for me."
26 |One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections.
31 |The bedding was hardly able to cover it and seemed ready to slide off any moment. His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. "What's happened to me? " he thought. It wasn't a dream.
32 |His room, a proper human room although a little too small, lay peacefully between its four familiar walls. A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer. Gregor then turned to look out the window at the dull weather. Drops of rain could be heard hitting the pane, which made him feel quite sad. "How about if I sleep a little bit longer and forget all this nonsense", he thought, but that was something he was unable to do because he was used to sleeping on his right, and in his present state couldn't get into that position. However hard he threw himself onto his right, he always rolled back to where he was.
33 |He must have tried it a hundred times, shut his eyes so that he wouldn't have to look at the floundering legs, and only stopped when he began to feel a mild, dull pain there that he had never felt before. "Oh, God", he thought, "what a strenuous career it is that I've chosen! Travelling day in and day out. Doing business like this takes much more effort than doing your own business at home, and on top of that there's the curse of travelling, worries about making train connections, bad and irregular food, contact with different people all the time so that you can never get to know anyone or become friendly with them. It can all go to Hell!"
34 |He felt a slight itch up on his belly; pushed himself slowly up on his back towards the headboard so that he could lift his head better; found where the itch was, and saw that it was covered with lots of little white spots which he didn't know what to make of; and when he tried to feel the place with one of his legs he drew it quickly back because as soon as he touched it he was overcome by a cold shudder. He slid back into his former position. "Getting up early all the time", he thought, "it makes you stupid. You've got to get enough sleep. Other travelling salesmen live a life of luxury. For instance, whenever I go back to the guest house during the morning to copy out the contract, these gentlemen are always still sitting there eating their breakfasts. I ought to just try that with my boss; I'd get kicked out on the spot. But who knows, maybe that would be the best thing for me."
35 |