{"record":{"id":"516d6c95cb2b09eb","repo":"jfeinstein10/SlidingMenu","slug":"scrollscale-must-be-between-0-and-1","errorCode":null,"errorMessage":"ScrollScale must be between 0 and 1","messagePattern":"ScrollScale must be between 0 and 1","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java","lineNumber":688,"sourceCode":"\t}\n\t\n\t/**\n\t * Set the touch mode margin threshold\n\t * @param touchmodeMarginThreshold\n\t */\n\tpublic void setTouchmodeMarginThreshold(int touchmodeMarginThreshold) {\n\t\tmViewBehind.setMarginThreshold(touchmodeMarginThreshold);\n\t}\n\n\t/**\n\t * Sets the behind scroll scale.\n\t *\n\t * @param f The scale of the parallax scroll (i.e. 1.0f scrolls 1 pixel for every\n\t * 1 pixel that the above view scrolls and 0.0f scrolls 0 pixels)\n\t */\n\tpublic void setBehindScrollScale(float f) {\n\t\tif (f < 0 && f > 1)\n\t\t\tthrow new IllegalStateException(\"ScrollScale must be between 0 and 1\");\n\t\tmViewBehind.setScrollScale(f);\n\t}\n\n\t/**\n\t * Sets the behind canvas transformer.\n\t *\n\t * @param t the new behind canvas transformer\n\t */\n\tpublic void setBehindCanvasTransformer(CanvasTransformer t) {\n\t\tmViewBehind.setCanvasTransformer(t);\n\t}\n\n\t/**\n\t * Gets the touch mode above.\n\t *\n\t * @return the touch mode above\n\t */\n\tpublic int getTouchModeAbove() {","sourceCodeStart":670,"sourceCodeEnd":706,"githubUrl":"https://github.com/jfeinstein10/SlidingMenu/blob/4254feca3ece9397cd501921ee733f19ea0fdad8/library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java#L670-L706","documentation":"setBehindScrollScale() is supposed to reject scroll scales outside [0,1] (parallax factor of the behind view). Due to a buggy condition (f < 0 && f > 1 can never both be true), the throw is actually unreachable in the shown source, but the intended contract is that values outside [0,1] are invalid.","triggerScenarios":"Calling setBehindScrollScale() with a negative value or a value greater than 1.0f. Note: because of the && bug, such calls currently pass through and may just render oddly instead of throwing.","commonSituations":"Passing a percentage like 50 instead of 0.5f; intending parallax >1 for inverted scroll (unsupported); copying a scale from another view system.","solutions":["Pass a value between 0.0f and 1.0f (e.g. 0.5f for half-speed parallax)","Clamp the value before calling: Math.max(0f, Math.min(1f, f))","Do not rely on the exception to catch bad input - validate yourself, since the library's check is ineffective"],"exampleFix":"// before\nslidingMenu.setBehindScrollScale(-0.5f);\n// after\nfloat scale = -0.5f;\nslidingMenu.setBehindScrollScale(Math.max(0f, Math.min(1f, scale)));","handlingStrategy":"validation","validationCode":"if (f < 0f || f > 1f) throw new IllegalArgumentException(\"scroll scale must be in [0,1]: \" + f);\nslidingMenu.setBehindScrollScale(f);","typeGuard":"static boolean isValidScrollScale(Float f) { return f != null && !f.isNaN() && f >= 0f && f <= 1f; }","tryCatchPattern":"try { slidingMenu.setBehindScrollScale(f); } catch (IllegalStateException e) { slidingMenu.setBehindScrollScale(1f); }","preventionTips":["Clamp values to [0,1] yourself; the library's own check (f < 0 && f > 1) is buggy and never throws","Use named constants like 0.5f for half parallax","Document that parallax >1 is unsupported"],"tags":["android","slidingmenu","range-validation","library-bug"],"backgroundTag":"value-out-of-range","analyzedSha":"4254feca3ece9397cd501921ee733f19ea0fdad8","analyzedAt":"2026-09-09T10:08:27.041Z","contentChangedAt":"2026-09-09T10:08:27.041Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}